I want to import products (categories) from XML.
Categories element is <type>RCA</type>
where "RCA" is category.
There is multiple categories i want.
For single category i used "/product[contains(type, "RCA")]"
although it worked it gave me all categories with word "RCA".
Also how can I filter multiple categories? When I did for example:
"/product[contains(type, "RCA" or type, "XLR" or "DVI" or "HDMI")]"
…it did not work.
2
Answers
From this answer I gather that you’d want to use something like:
Not tested but worth a try.
Try this:
This uses contains the other way around.
There might be a problem with
/product
(single slash). This normally will only select the root-element. If you want only child::product use it without any slashproduct
or./product
. If you want all descendants use.//product
ordescendant::product
If you have even more categories the XPath is safer with the spaces surrounded it wil only match these types and not types that are inside each other, like ONE and ONES