EZ Question: Read XML into an array

webmasterbeta

New Member
I am reading the following array:

<Test_CAWSProducts>
<Test_CAWSProduct>
<ProductID>FRSXD1B11W</ProductID>
<Price>100</Price>
<Quantity>1</Quantity>
<Duration>7</Duration>
<DurationType>Day</DurationType>
<ResumeGeographicScope>DirectMarketArea</ResumeGeographicScope>
<ResumeGeographicValue>602</ResumeGeographicValue>
</Test_CAWSProduct>
<Test_CAWSProduct>
<ProductID>FRPRI10B</ProductID>
<Price>200</Price>
<Quantity>10</Quantity>
<Duration>12</Duration>
<DurationType>Month</DurationType>
<ResumeGeographicScope>None</ResumeGeographicScope>
<ResumeGeographicValue></ResumeGeographicValue>
</Test_CAWSProduct>
</Test_CAWSProducts>

using this code in VB.Net:

_sXpathExpression = _sXpathExpression & "Test_CAWSProducts/Test_CAWSProduct/"
_xmlNodes = _xmlDoc.SelectNodes(_sXpathExpression & "*")

For Each _xmlNode In _xmlNodes
_arTest_CAWSProduct(i) = New CAWSProduct
_arTest_CAWSProduct(i).ProductID = _xmlNode.SelectSingleNode(_sXpathExpression & "ProductID").InnerText
_arTest_CAWSProduct(i).Price = CType(_xmlNode.SelectSingleNode(_sXpathExpression & "Price").InnerText, Decimal)
_arTest_CAWSProduct(i).Quantity = CType(_xmlNode.SelectSingleNode(_sXpathExpression & "Quantity").InnerText, Integer)
_arTest_CAWSProduct(i).Duration = CType(_xmlNode.SelectSingleNode(_sXpathExpression & "Duration").InnerText, Integer)
_arTest_CAWSProduct(i).DurationType = _xmlNode.SelectSingleNode(_sXpathExpression & "DurationType").InnerText
_arTest_CAWSProduct(i).ResumeGeographicScope = _xmlNode.SelectSingleNode(_sXpathExpression & "ResumeGeographicScope").InnerText
_arTest_CAWSProduct(i).ResumeGeographicValue = _xmlNode.SelectSingleNode(_sXpathExpression & "ResumeGeographicValue").InnerText
i = i + 1
Next

But my _xmlNode is not incrementing and I end up all rows of the array set to the same values.

Please help!
 
Back
Top