XPath Contains problem.

Last post 05-09-2008 5:16 AM by coolblue. 2 replies.

Sort Posts:

  • XPath Contains problem.

    05-09-2008, 4:31 AM
    • Loading...
    • coolblue
    • Joined on 11-30-2005, 7:03 AM
    • Posts 122
    I have the following XML:-

    <doc>
      <animal value="Dog">
        <type value="Mammal Canine" />
        <legs value="4" />
      </animal>
      <animal value="Cat">
        <type value="Mammal Feline" />
        <legs value="4" />
      </animal>
      <animal value="Tasmainian Devil">
        <type value="Mammal Marsupial" />
        <legs value="4" />
      </animal>
    </doc>

    How do I select all 'Animal' nodes that have a 'type' node with an attribute value that contains 'Mammal'?
  • Re: XPath Contains problem.

    05-09-2008, 5:10 AM
    Answer
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 304
    Try out something linke this: /doc/animal[contains(./type/@value,'Mammal')]
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
  • Re: XPath Contains problem.

    05-09-2008, 5:16 AM
    • Loading...
    • coolblue
    • Joined on 11-30-2005, 7:03 AM
    • Posts 122
    Thank you. That works perfectly.
Page 1 of 1 (3 items)