I’m struggling with the BizTalk xpath functionality
– the message I’m getting has a blank default namespace
– in C# I’d add a NameSpaceManager
– but I can’t see how I can do this in a BizTalk Expression ?
All I’m failing to do is get the values of the HasErrors and NumberOfErrors
<?xml version="1.0" encoding="utf-8"?>
<ImportIndexDocumentResponse
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.aniteps.com/xml/schemas/awm/images4">
<HasErrors>false</HasErrors>
<NumberOfErrors xsi:type="xsd:int">0</NumberOfErrors>
<ErrorDescription xsi:type="xsd:string">No exception ocurred.</ErrorDescription>
...
The answer using
local-name()is wrong as it allows unwanted elements to be selected, such as:Here is one correct solution:
In case it is not possible to bind a prefix to the default namespace “http://www.aniteps.com/xml/schemas/awm/images4“, one can use the standard XPath function
namespace-uri()to specify that the element must reside in a given namespace.Thereforere, one example of XPath expressions that select the wanted two kind of nodes is:
/*/*[namespace-uri() = 'http://www.aniteps.com/xml/schemas/awm/images4' and name() = 'HasErrors' ]and the expression:
/*/*[namespace-uri() = 'http://www.aniteps.com/xml/schemas/awm/images4' and name() = 'NumberOfErrors' ]