当命名空间放入元素时,为什么这个xpath不起作用?

时间:2011-06-22 10:05:01

标签: xml xpath

我有这个xml:

<?xml version="1.0" encoding="UTF-8"?>
<EchoWithPostResponse xmlns="http://tempuri.org/">
    <EchoWithPostResult>
        Hello World
    </EchoWithPostResult>
</EchoWithPostResponse>

当我使用xpath时:

  

/ EchoWithPostResponse / EchoWithPostResult

没有选择任何内容。但是,当我取出它的命名空间时(内部节点被选中),所以当我有这个xml:

<?xml version="1.0" encoding="UTF-8"?>
<EchoWithPostResponse>
  <EchoWithPostResult>
    <add key="AuthDllPath" value="" />
  </EchoWithPostResult>
</EchoWithPostResponse>

我如何解释命名空间,遗憾的是我不能将它们取出。

2 个答案:

答案 0 :(得分:2)

您需要声明并使用命名空间。

答案 1 :(得分:0)

/a:EchoWithPostResponse/a:EchoWithPostResult