I want to import all products filtering these they applied all 3 criteria:
1) they are in stock (DIM)
2) stock is more than 3 pcs (stock_indicator
)
3) and they belong to one (any) of these groups 1 or 4
I want all 3 criteria, but in 3rd any of these options
i.e.:
/product[dim1[1] = "1" and stock_indicator[1] > 3 and group[1] = "1" or group/category/id[1] = "4"]
The above does not returns any product, like no product have all these requirements.
What am I doing wrong?
Dim = availability
2
Answers
First of all your XPath assumes that all
product
elements are at root level, which would not make for a well-formed XML document; the all should be wrapped in some element.If that is no problem in your environment (since we do not know the whole setup from your question) probably the most prominent problem in your XPath is that you try to compare the value of
stock_indicator
against axs:integer
but in fact your data sample encodes them asxs:string
.Consequently
will always return
false
…Try
or
instead.
Nevertheless depending on the data structure (e.g. multiple
stock_indicator
elements in oneproduct
[whatever that might mean]) this could return false positives.You can use the following XPath to filter the products :
//
at the beginning as stated by @Benjamin W. Bohl to catch all productsavailability
is used instead of "Dim"[1]
) assuming you only have 1availability
, 1stock_indicator
, 1id
pergroup
in eachproduct
XML used to test.
XPath :
XML is filtered (2 of the 4 products fulfill the conditions) :