XPath

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SiJP

    #1

    XPath



    Consider the following XML

    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
    <Data>
    <ID>1005</ID>
    <Reference>
    <Reference>AB C</Reference>
    <Country>UK</Country>
    </Reference>
    <Reference>
    <Reference>12 3</Reference>
    <Country>USA</Country>
    </Reference>
    </Data>
    </Root>


    Using XPath, I would like to: Select the value of the Reference Node,
    Where the ID = 1005, And the Country is USA. The value of the node
    would therefore be 123.

    I'm not great with XPath, but had a go and got it completely wrong:
    XPath = "//Data/[ID ="1005"]/../Reference/[Country="USA"]/Reference"

    I'd be ever so grateful if someone can help out with this XPath!

    Cheers
    Simon


    (If its any help, I'm using vs.net 2005 and trying to populate an
    XPathNodeIterat or using XPathNavigator. Select)

  • SiJP

    #2
    Re: XPath

    Thanks very much guys. I wasn't far off, but now understand where I
    went wrong!

    Merrry Christmas,

    Simon

    Comment

    Working...