Searching for multiple types with XPath
-
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[^]
-
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[^]
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
-
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[^]
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.