Hi everybody,

I have this XML file,,

<users type="array">
  <name>Ronsna Stedinberg</name> 
  <location>New York</location> 
  <name>Sonsna Dtedinberg</name> 
  <location>Las Angeles</location> 

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.)



Recommended Answers

All 3 Replies

Use System.XML namespace DOM classes.

getElementsByTagName method.

System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
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, learning, and sharing knowledge.