Hi everybody,

I have this XML file,,

<users type="array">
 <user>
  <id>12345567</id> 
  <name>Ronsna Stedinberg</name> 
  <screenname>Donnsax</screenname> 
  <location>New York</location> 
 </user>
 <user>
  <id>12345568</id> 
  <name>Sonsna Dtedinberg</name> 
  <screenname>Nonnsax</screenname> 
  <location>Las Angeles</location> 
 </user>  
</users>

and I wonder how can I read all the id's info in the xml?
(the <user> </user> is repeat 50 times, so I have 50 id's.)

Thanks.

Ron,

Use System.XML namespace DOM classes.

getElementsByTagName method.

.....      
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(@"c:\csnet\46\CSonsole\a1.xml");
System.Xml.XmlElement root = doc.DocumentElement;
System.Xml.XmlNodeList lst = root.GetElementsByTagName("id");

  foreach (System.Xml.XmlNode n in lst)
        {
            Console.WriteLine(n.InnerText);  // print id text
        }

Thank You! It's Work! :icon_exclaim: :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.