2012-10-09 61 views
0

我有以下XPATH,它似乎是爲類別選擇正確的產品,但是當我的XPath中的qtyInStock值爲0時,我錯誤地選擇了產品我的狀態qtyInStock> 0。任何人都可以看到這個錯誤,我認爲我的語法不正確。XPATH語法從XML中選擇產品

/產品/產品[類別= 1234或additionalCategories/CATID = 1234 和qtyInStock> 0]

<?xml version="1.0" encoding="UTF-8"?> 
<products> 
<product> 
<prod_id>2100818</prod_id> 
<productURL></productURL> 
<productImageURL>jb-m-kirichigai-draw-6.jpg</productImageURL> 
<category>448267</category> 
<qtyInStock>2</qtyInStock> 
<featured>1</featured> 
<Hidden>0</Hidden> 
<productName>1.5 Sun Kirichigai 6 Step with Draw Japanese Puzzle Box</productName> 
<livePrice>39.4</livePrice> 
<fullURL>http://www.faze3.co.uk/index.aspx?pageID=527917&amp;prodID=2100818</fullURL> 
</product> 
<product> 
<prod_id>2101600</prod_id> 
<productURL></productURL> 
<productImageURL>jb-2-kiasa-7.jpg</productImageURL> 
<category>448267</category> 
<qtyInStock>1</qtyInStock> 
<featured>1</featured> 
<Hidden>0</Hidden> 
<productName>2 Sun Kiasa 7 Step Japanese Puzzle Box</productName> 
<livePrice>28.4</livePrice> 
<fullURL>http://www.faze3.co.uk/index.aspx?pageID=527917&amp;prodID=2101600</fullURL> 
</product> 
<product> 
<prod_id>2101795</prod_id> 
<productURL></productURL> 
<productImageURL>jb-2-koyosegi-7.jpg</productImageURL> 
<category>448267</category> 
<qtyInStock>2</qtyInStock> 
<featured>1</featured> 
<Hidden>0</Hidden> 
<productName>2 Sun Koyosegi 7 Step Japanese Puzzle Box</productName> 
<livePrice>25.95</livePrice> 
<fullURL>http://www.faze3.co.uk/index.aspx?pageID=527917&amp;prodID=2101795</fullURL> 
</product> 
<product> 
<prod_id>2102219</prod_id> 
<productURL></productURL> 
<productImageURL>jb-2-kuroasa-10.jpg</productImageURL> 
<category>448267</category> 
<qtyInStock>0</qtyInStock> 
<featured>1</featured> 
<Hidden>0</Hidden> 
<productName>2 Sun Kuroasa 10 Step Japanese Puzzle Box</productName> 
<livePrice>34.8</livePrice> 
<fullURL>http://www.faze3.co.uk/index.aspx?pageID=527917&amp;prodID=2102219</fullURL> 
</product> 
+0

你試過:'/產品/產品[(類別= 1234或additionalCategories/CATID = 1234)和qtyInStock> 0]' – Pawel

回答

1

and操作符比or操作者更高的優先級。詳情請參閱here

而是嘗試下面的(注意用括號分組)

/products/product[(category = 1234 or additionalCategories/catID =1234) and qtyInStock > 0]