开发者

How to select a node without attributes using xpath?

Let say that I have xml like this:

<root>
    <node light="somevalue">message1</node>
    <node dark="somevalue">message2</node>
    <node>message3</node>
</root>

开发者_StackOverflow中文版With xpath usage I need to get "message3".

Does anybody know how I can achieve this?


I think you mean that you want to select nodes without attributes.

From XPath: How to select nodes which have no attributes?

//node[not(@*)]

This will select all nodes that do not have attributes.


/root/node[not(@*)]/text()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜