Well there are many ways of doing this, you can use XmlReader to read the
XML doc or you can use XPath to get the nodes that you want. Depending on
the your situation you should choose the one that suit you best.
XPath is the most convenient - imho, so I would do:
XmlNodeList surveyList = xmlDoc.SelectNodes("//UserData/Survey");
foreach (XmlNode surveyNode in surveyList)
{
Console.WriteLine(surveyNode.Attributes["ID"].InnerText);
XmlNodeList userList = surveyNode.SelectNodes("User");
foreach (XmlNode userNode in userList)
{
Console.WriteLine(" " + userNode.Attributes["ID"].InnerText);
}
}
---
Victor Hadianto
http://www.synop.com/Products/SauceReader/
"Shailendra Batham" <sh********@sitesystems.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
hey xml gurus
I have a xml which is as follows, so my question is how can I read this
XML is VB.Net or C#. I want to loop for every survey ID and insider
every survey I want to loop for each user ID and get their values.
<?xml version="1.0" encoding="utf-8"?>
<UserData>
<Survey ID="S1">
<User ID="U1">
<EmailAddress>u1@ss.com</EmailAddress>
</User>
<User ID="U2">
<EmailAddress>u2@ss.com</EmailAddress>
</User>
</Survey>
<Survey ID="S2">
<User ID="U4">
<EmailAddress>u4@ss.com</EmailAddress>
</User>
</Survey>
</UserData>
thanks,
shailendra
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!