473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Read complex XML into a dataset or XMLDeSerializer

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!
Nov 12 '05 #1
1 4252
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!

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: feel | last post by:
Hi, i need to read data from an Access Database. My problem is that all data have to be parsed or calculated so i'm looking for the fastest way. How to do that? Do i need a dataset or two...
1
by: stormogulen | last post by:
Hi! I'm hoping someone can help me come up with a 'best possible solution' for the following problem: I'm trying to design an addressbook, i.e a storage for adresses. I would like my adresses...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
1
by: D. Shane Fowlkes | last post by:
How can I loop through the rows of a DataSet and send the "fields" to the Function as I've attempted to do in my code? Error is at "While dsLineItems.Read()" . I'm trying to construct a Sub which...
2
by: Travis | last post by:
I am new to VB.NET and I am trying to use a complex bind for a combo box. I have successfully created a data set, I have set my DataSource value to the dataset and the DisplayMember value to the...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
2
by: Jerod Hatley | last post by:
Can someone point me to a good document on creating and passing complex datatypes to and from a web service? I would like to pass a master / detail object. The object would hold the master...
0
by: Hetal | last post by:
Hi there.. I am a VB6 developer so kinda trying to figure how to work with VB.NET. I have a scenario where i have a DataSet bound to a combo box, and i would like to read a row from the DataSet...
6
by: Jon Bilbao | last post by:
I´m trying a select clause in two steps because it´s too complex. First: SELECT Reference, Results.idEnsayo, Results.Num_taladro, min(Results.dTime) + 500 AS tIni, max(Results.dTime) - 500 AS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.