Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: xPath question

  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    xPath question

    hi,
    i'm currently working on a project in VB.NET. the xml structure i want to query looks something like this:
    <cid>
    <c1>
    <id></id>
    <id></id>
    [etc]
    </c1>
    <c2>
    <id></id>
    [etc]
    </c2>
    </cid>

    now, would an xpath expression like this
    xmldoc.DocumentElement.SelectNodes("/cid/c" & c_index & "//id")
    work to select all the "id"-nodes that are childnodes of one specific "c[anynumber]" node, where c_index is the number i want to look at?
    sorry for the kinda confusing description, but i dont really know how to explain it better.
    thanks a lot,
    peph.halmen

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,237
    Thanks
    12
    Thanked 340 Times in 336 Posts
    if SelectNodes() accepts only an XPath expression, this is certainly wrong. conditions you have to define in []
    Code:
    // final XPath expression
    // note that index numbers start with 1
    
    /cid/c[c_index]/id
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

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