我有以下 XML 语法:
<Properties>
<Property>
<Name>Author</Name>
<Type>Object</Type>
<Value>somevalue</Value>
</Property>
<Property>
<Name>Title</Name>
<Type>String</Type>
<Value>Word files</Value>
</Property>
<Property>
<Name>Path</Name>
<Type>String</Type>
<Value>/path/subfolder/directory/somevalue.doc</Value>
</Property>
<Property>
<Name>Rank</Name>
<Type>Int64</Type>
<Value>804</Value>
</Property>
<Property>
<Name>Size</Name>
<Type>Int64</Type>
<Value>0</Value>
</Property>
</Properties>
基本上这是 1 个这样的属性集,我还有大约 10 个。我需要访问 Value 节点中的文本,以及相对于名称标签 [Author,Title,Path,Rank,Size] 中包含的 text()。本质上,我的 XPathQueries 返回一组标记文本。
我的处理方法是这样的:
XPathQuery("//属性/名称//*text()='Author']/Type/Value");
但那是行不通的人!现在我离把头发撕开还有 20 分钟的路程:(
作为记录,如果重要的话,我正在使用 java Xpath 库,因为我正在用 Java 编程。