Results 1 to 2 of 2

Thread: [2.0]Select multiple nodes using XPathNodeIterator (XML)

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    [2.0]Select multiple nodes using XPathNodeIterator (XML)

    Hi guys good day. I have this trouble about selecting multiple nodes in an xml file.
    Code:
    <record>
        <cat>hw</cat>
        <subcat>monitoring</subcat>
        <Name>drives</Name>
        <Index>0</Index>
        <Type>array</Type>
        <Value>IDE\DiskST340014A</Value>
      </record>
    i.e I want to select the value of Index and Value.
    What I have here is just select a single value of a certain node. I've tried putting + sign ("//record[Name='drives']/Index + /Value"but no luck. Any idea?
    Code:
    XmlTextReader xtr = new XmlTextReader("c:/sample.xml");
    			XPathDocument xpath = new XPathDocument(xtr, XmlSpace.Preserve);
    			XPathNavigator xnav = xpath.CreateNavigator();
    			string strquery = "//record[Name='drives']/Index";			
    			XPathNodeIterator ite = xnav.Select(strquery);
    			while(ite.MoveNext()){
    				Console.WriteLine(ite.Current.Value);
    			}

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [2.0]Select multiple nodes using XPathNodeIterator (XML)

    //record[Name='drives']/Index | //record[Name='drives']/Value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width