Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Searching for multiple types with XPath

Searching for multiple types with XPath

Scheduled Pinned Locked Moved XML / XSL
xmlalgorithmsperformancequestion
3 Posts 3 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    If I have a category, e.g. 'fish' and within that three sub-categories 'fish1', fish2' and 'fish3' is it possible to use XPath in a way to filter 'fish1' and 'fish3'? I am looking at using XML for in memory representation of data and need to support multiple selection of data types. Thanks.

    Join the cool kids - Come fold with us[^]

    N S 2 Replies Last reply
    0
    • L Lost User

      If I have a category, e.g. 'fish' and within that three sub-categories 'fish1', fish2' and 'fish3' is it possible to use XPath in a way to filter 'fish1' and 'fish3'? I am looking at using XML for in memory representation of data and need to support multiple selection of data types. Thanks.

      Join the cool kids - Come fold with us[^]

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      I haven't tested it specifically but you should be able to use this //fish[fish1 || fish3]


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • L Lost User

        If I have a category, e.g. 'fish' and within that three sub-categories 'fish1', fish2' and 'fish3' is it possible to use XPath in a way to filter 'fish1' and 'fish3'? I am looking at using XML for in memory representation of data and need to support multiple selection of data types. Thanks.

        Join the cool kids - Come fold with us[^]

        S Offline
        S Offline
        sameerazazi87
        wrote on last edited by
        #3

        Hi check out below XML

        <fish>
        <fish1>
        <name> f1 </name>
        </fish1>
        <fish2>
        <name> f2 </name>
        </fish2>
        <fish3>
        <name> f3 </name>
        </fish3>
        </fish>

        and you want to select this fish1 and fish3 then use belwo xpath /fish/*[contains('fish1fish3',name())] this will give you NodeList which will contain fish1 and fish3 nodes if your filter includes number of nodes so that writing each name is inefficient then you should use another approach.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups