CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2000
    Location
    UK
    Posts
    122

    What XPATH expression to use

    I need an XPATH expression to to the following

    I have a DOM as below

    <Data>
    <Object>
    <A ExternalId="A"/>
    <B ExternalId="B"/>
    <A ExternalId="C"/>
    <B ExternalId="D"/>
    </Objects>
    </Data>


    I am looking for an XPath expression that will give me the node
    <A ExternalId="C"/>

    However all I know is that the node is a first level child of "/Data/Objects" and that it has an attribute "ExternalId" with a value of "C"

    I tried the following but it doesnt work

    oDOM.selectSingleNode("/Data/Objects/.[@ExternalId='C']")

    Any ideas
    All code on this page is protected by an SEP field!!!

  2. #2
    Join Date
    Apr 2002
    Location
    Seattle, WA, USA
    Posts
    97
    You're close, but your xml is invalid to begin with.
    Code:
    <Data>
      <Objects>
        <A ExternalId="A"/>
        <B ExternalId="B"/>
        <A ExternalId="C"/>
        <B ExternalId="D"/>
      </Objects>
    </Data>
    A valid XPath would be "/Data/Objects/A[@ExternalId='C']"

  3. #3
    Join Date
    Feb 2003
    Location
    North Carolina
    Posts
    57
    You may want to try this nice utility that I came across called XPath Explorer.
    XPath Explorer
    It works great for figuring out how to code those complex xpath commands.

    Mark

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

Featured