开发者

Why doesnt this xpath work when a namespace is put into the element?

I have this xml:

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

When I use the xpath:

/EchoWithPostResponse/EchoWithPostResult

Nothing gets selected. However when I take out the namespace it works (the inner node is selected s), so when I have this xml:

<?xml version="1.0" encoding="UTF-8"?>
<EchoWithPostResponse>
  <EchoWithPostResult>
    <add key="Aut开发者_StackOverflowhDllPath" value="" />
  </EchoWithPostResult>
</EchoWithPostResponse>

How do I account for the namespace, I cant really have them taken out unfortunately.


You need to declare and use the namespace.


/a:EchoWithPostResponse/a:EchoWithPostResult
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜