0
Answer

How to use for each loop for xml

kalu singh rao

kalu singh rao

10y
725
1
I want to get string xml attributes value in object. But i have multiple data node in string xml then i want to use for each loop for get value of node.But i am little confusing how and where can i use for each loop in following code.
 
ProcessVals = <PassScroll>
<Pass LedgerName="SB FORMS" SerialFrom="1" SerialTo="100" Qty="10" Rate="10.000000" IssuedQty="10" />
<Pass LedgerName="CD FORMS" SerialFrom="1" SerialTo="2500" Qty="50" Rate="15.000000" IssuedQty="10" />
</PassScroll>
 
Dim root As XElement = XElement.Parse(ProcessVals)
Dim child = root.Element("Pass")
For Each rt As XElement In child

Dim passScroll As PassScroll = New PassScroll
Dim pass As New Pass

pass.LedgerName = child.Attribute("LedgerName").Value
pass.SerialFrom = Convert.ToInt32(child.Attribute("SerialFrom").Value)
pass.SerialTo = Convert.ToInt32(child.Attribute("SerialTo").Value)
pass.Qty = Convert.ToInt32(child.Attribute("Qty").Value)
pass.Rate = Convert.ToDouble(child.Attribute("Rate").Value)
pass.IssuedQty = Convert.ToInt32(child.Attribute("IssuedQty").Value)
passScroll.Pass = pass
Next
 
 Any help will appreciate. Thank you in advance.