DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: XPath to return sibling data

  1. #1
    Join Date
    Apr 2009
    Posts
    5

    XPath to return sibling data

    What to create XPath(s) that I can can use in a FOR loop to retrieve each of the <app> and <coapp> fname & mname. Want my result to be "1 - Danny L", "2 - Wendy R", "3 - Brenda", "4 - Tim G". I have played with this XPath and just cannot get it right.

    Code:
    <?xml version="1.0"?>
    <root>
     <data>
       <app>
         <curr_fname>Danny</curr_fname>
         <curr_mname>L</curr_mname>
         <prev_fname>Wendy</prev_fname>
         <prev_mname>R</prev_mname>
       </app>
       <coapp>
         <curr_fname>Brenda</curr_fname>
       </coapp>
       <coapp>
         <curr_fname>Tim</curr_fname>
         <curr_mname>G</curr_mname>
       </coapp>
     </data>
    </root>

  2. #2
    Join Date
    Apr 2009
    Posts
    5
    A bit more information - the FOR loop will be written in vb.net. Something like the following. The retrieval of data from the xml doc must be in an XPath. There is no flexibility.


    Code:
    Dim node As XmlNode
    
    For i = 1 to 10
    
       xpath = "(\root\data\app |\root\data\coapp)[" & i  & "] (curr_fname | prev_fname)"
       node1 = xml.SelectSingleNode(xpath)
       xpath = "(\root\data\app |\root\data\coapp)[" & i  & "] (curr_mname | prev_mname)"
       node2 = xml.SelectSingleNode(xpath)
         Field = Field + ", " & node.innertext & " " & node.innertext   
    Next i

Similar Threads

  1. Replies: 0
    Last Post: 05-22-2007, 02:19 AM
  2. Binary Tree Help
    By TheJVM_1970 in forum Java
    Replies: 2
    Last Post: 12-05-2005, 01:23 AM
  3. Directional help
    By Code_Nerd in forum Java
    Replies: 0
    Last Post: 10-18-2005, 04:46 AM
  4. Replies: 0
    Last Post: 03-01-2003, 09:17 AM
  5. Is inheritance overrated?
    By Phil Weber in forum .NET
    Replies: 67
    Last Post: 12-15-2002, 02:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center