現實的問題:我使用XPath 1.0與2.0語法,所以下面不工作:/root/row/checks[not(taxAmount = sum(selections/tax))]/sum(selections/tax/text())
XPATH:在子節點一筆不整XPATH
我有以下XPATH:
/root/row/checks[./taxAmount/text() != sum(./selections/tax/text())]/selections/tax/text()
我想要的東西,像下面這樣:
/root/row/checks[./taxAmount/text() != sum(./selections/tax/text())]/sum(selections/tax/text())
我不想總結整個陳述,只是子節點在/選擇,但我迄今試過的結果在語法錯誤
本質上,我有檢查標題信息不匹配的細節信息,並希望總結細節以與頭部進行比較。
示例XML:
<root>
<row>
<checks>
<selections>
<tax>1.00</tax>
</selections>
<selections>
<tax>2.00</tax>
</selections>
<selections>
<tax>1.14</tax>
</selections>
<taxAmount>4.14</taxAmount>
</checks>
<checks>
<selections>
<tax>1.00</tax>
</selections>
<selections>
<tax>0.50</tax>
</selections>
<selections>
<tax>1.00</tax>
</selections>
<taxAmount>3.00</taxAmount>
</checks>
<checks>
<selections>
<tax>1.00</tax>
</selections>
<selections>
<tax>0.50</tax>
</selections>
<selections>
<tax>1.25</tax>
</selections>
<taxAmount>5.00</taxAmount>
</checks>
</row>
</root>
編輯根據丹尼爾的回答是:
這並不完全是我所期待的。這將選擇與問題的檢查,但我想是這樣的:
/根/行/檢查[未(TAXAMOUNT = SUM(選擇/含稅))]/TAXAMOUNT /文()
3.00
5.00
/根/行/檢查[否(TAXAMOUNT =總和(選擇/稅))] /總和(選擇/稅/文本())
2.50
2.75
你能告訴我們你的XML文檔的樣本? – skovorodkin