XPath and listing the child node names / values

Posted on 2006-05-29
Last Modified: 2012-06-27
I am reading from an RSS XML Document and am having trouble listing the child elements of the <item> node.

What I need to do is get a list of all the child node names and values of the <item> node.

I'm fairly new to XPath and cant find a way to iterate through the child elements.... Below is my code:

                ArrayList otherNodes = new ArrayList();


                while (xpNav.MoveToNext())
                    //string tt = x.ChildNodes[k].Name;
                    otherNodes.Add(xpNav.Name + "&&" + xpNav.Value);
Question by:SuperGhosty
    LVL 11

    Accepted Solution

    XPathDocument Doc = new XPathDocument("<yourXmlFile>");
    XPathNavigator navigator = Doc.CreateNavigator();
    XPathNodeIterator iterator = navigator.Select("<yourPathInsideTheXml>");
    while (iterator.MoveNext())
    //... do something with iterator.Curent

    LVL 6

    Assisted Solution

    LVL 5

    Assisted Solution

    If you are having trouble with XPATH try the Visual XPath tool.  Here is the description from gotdotnet for Visual XPath:

    "Used to test XPath queries and Performance times. It runs XPath queries and displays the result. Also the queries can be automatically generated by selecting XML nodes in the TreeView."



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now