Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これは私のXPath操作です:
XPathExpression source = xpath.compile("@source/text()");
メイン ドキュメントの別の XPath 操作によって作成されたノード リストをループしています。だから私はsourceこのように呼んでいます:
source
(NodeList)source.evaluate(list.item(x), XPathConstants.NODESET);
結果のノード リストは常に空です。何故ですか?
@source/text()は無効です: @sourceは属性であり、属性には子ノード (テキストまたはその他) がありません。
@source/text()
@source
単純に使用する必要があります@source。
list.item(x)(XML を見ると役に立ちますが、それは属性を持つことができる XML 要素であると想定していsourceます)
list.item(x)