Forum Discussion

sridevi86's avatar
15 years ago

Adding XPATH to XML without namespaces

The response data in the services I use returns an XML response. But it doesn't have a namespace associated with it. Please let me know how to add XPATH assertions when XML output doesn't have a namepsace.

1 Reply

  • I know this is an old post, but I found it in my search for the same info and I've solved the issue.

    I have XML that looks like this:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <LoginResponse xmlns="http://example.com/WebServices/">
    <SessionID>xxx</SessionID>
    <LoginResult>Success</LoginResult>
    </LoginResponse>
    </soap:Body>
    </soap:Envelope>


    So the XPath can look like this:

    declare namespace b='http://example.com/WebServices/'
    //b:LoginResponse


    Notice that the response XML doesn't use the 'b' namespace, but I'm assigning the default namespace URL to b in the XPath query and then using 'b' in the query. This worked for me.