开发者

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

开发者 https://www.devze.com 2023-03-14 10:21 出处:网络
I have this xml: <?xml version=\"1.0\" encoding=\"UTF-8\"?> <EchoWithPostResponse xmlns=\"http://tempuri.org/\">

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

精彩评论

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