How to make an XPath expression in XML with multiple namespaces?


I have the following xml:

<root xmlns:S="">
    <body xmlns="">
                <nomeSerasa />

I want to validate the value of the decision element, for that I use the expression:

string(//decision) = 'ACCEPT'

And the expression works, if I remove any of the namespaces from the document, the way it is, the expression always returns false because it can't get to the element's value.

How do I fix the expression to work with 2 or more namespaces?

PS: I've also tested it using XPath /root/body/checkCredit/CheckCreditOut/addresses/decision


You can use the XPath local-name function:

/*[local-name() = 'checkCredit']/*[local-name() = 'CheckCreditOut']/*[local-name() = 'addresses']/*[local-name() = 'decision']
Scroll to Top