Hi I have xmlFile like below .My problem is that I cant iterate through all nodes.I have tried something like this .But I think its to diffucult for me .I am so cunfused.How can do this without Linq To Xml

protected void Page_Load(object sender, System.EventArgs e)
    {
        string xmlFile = Request.PhysicalApplicationPath + @"myxml.xml";
        XmlReaderSettings settings = new XmlReaderSettings();
        settings.IgnoreComments = true;
        settings.IgnoreWhitespace = true;

        using (XmlReader reader = XmlReader.Create(Server.MapPath("myxml.xml"), settings)) {
            while (reader.Read()) {
                string xmlContent = "";
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "Book") {

                    while (reader.NodeType != XmlNodeType.EndElement)
                    {



                    }
                    Label1.Text = xmlContent;
                }

            }

        }

    }

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This is sample book store xml file.-->
<books>
  <book>
    <id>1</id>
    <name>Photodex ProShow: Visual QuickStart Guide</name>
    <author>Jon Canfield</author>
    <price>$29.99</price>
    <type>Photoshop</type>
  </book>

</books>

I think that this is the simplest way to do this.

List<string> list=new List<string>();
XmlDocument doc = new XmlDocument();
                doc.Load("string path or url");
                XmlNodeReader nodereader = new XmlNodeReader(doc);
                while (nodereader.Read())
                {
                    if (nodereader.NodeType == XmlNodeType.Element)
                        list.Add(nodereader.LocalName);
                }
            }
            foreach (string node in list) 

            {
                MessageBox.Show(node);
            }

if you .xml file is located on your hard drive than use the OpenFileDialog class otherwise if it s on the web that put your url as a string.

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.