我正在使用tinyxpath-1.3.1。 Linux上的C/C++。當我在文檔上進行xpath搜索時,我認爲我應該找不到節點。在tinyxpath中給出錯誤匹配和不匹配的屬性比較
我的XML:
<data>
<event deviceId="25479545.5" interface="sensor-multilevel"
command="state" label="luminance" newValue="800"
oldValue="9" time="1412227484" />
</data>
我的XPath表達式:
/data/event[@deviceId="25479545.5" and @interface="sensor-multilevel" and
@label="luminance" and @newValue>600 and @oldValue<10]
如果我參加了oldValue
並使用()
這樣的比較工作:
/data/event[(@deviceId="25479545.5" and @interface="sensor-multilevel") and
(@label="luminance" and @newValue>600)]
有一些限制比較的數量?
將600轉換爲小數的任何特殊情況?
我需要「」600的價值,它似乎無論如何工作。
關於如何使它與表達式中包含的oldValue屬性一起工作的任何想法?
TinyXPath電話:
TiXmlNode * node = TinyXPath::XNp_xpath_node(root, expression.c_str());
感謝 拉里
如果你忽略'oldValue'而不使用括號會發生什麼? – 2014-10-06 22:22:39
如果我遺漏了oldValue並且沒有使用parnethesis,它將無法匹配。 – 2014-10-06 22:27:14
我剛剛在http://www.freeformatter.com/xpath-tester.html上試過了你的xpath表達式。它只有在我用'<' and '>'代替'<'和'>'代碼時纔有效。你可以試試嗎? – 2014-10-06 22:36:25