【发布时间】:2013-02-21 11:55:05
【问题描述】:
我有以下 xml。我需要使用 xpath 查询获取根节点的所有子节点。如何编写 xpath 表达式?
<rootElement>
<rootElementOne xmlns="http://some.com">
<rootElementTwo>
<Id>12345</balId>
<name>Name1</businessName>
</rootElementTwo>
</rootElementOne>
<rootElementOne xmlns="http://some.com">
<rootElementTwo>
<Id>6789</balId>
<name>Name2</businessName>
</rootElementTwo>
</rootElementOne>
</rootElement>
表达式应返回以下结果:
<rootElementOne xmlns="http://some.com">
<rootElementTwo>
<Id>12345</balId>
<name>Name1</businessName>
</rootElementTwo>
</rootElementOne>
<rootElementOne xmlns="http://some.com">
<rootElementTwo>
<Id>6789</balId>
<name>Name2</businessName>
</rootElementTwo>
</rootElementOne>
我尝试使用rootElement/rootElementOne/*,但没有结果。
谢谢!
【问题讨论】:
-
你试过
/rootElement/rootElementOne吗? -
@beny23:注意
<rootElementOne>上的默认命名空间声明。