Exitos
Exitos

Reputation: 29720

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="AuthDllPath" value="" />
  </EchoWithPostResult>
</EchoWithPostResponse>

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

Upvotes: 0

Views: 137

Answers (2)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56162

/a:EchoWithPostResponse/a:EchoWithPostResult

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798626

You need to declare and use the namespace.

Upvotes: 2

Related Questions