How To: Ignore Namespaces and Prefixes with XPath Based Tasks

Several of the the tasks in Sentry utilize XPath for targeting a specific node of an XML document. 

A Sentry use case may call for ignoring prefixes and namespaces while using XPath.  This can be accomplished by using a custom XPath expression with the local-name function.

 

The local-name function returns the name of the current node or the first node in the specified node set - without the namespace prefix. For more info see:

https://www.w3.org/TR/xpath/

 

Example

For the following XML:

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<s0:Echo xmlns:s0="http://crosschecknet.com/">
<s0:Buf/>
</s0:Echo>
</soap:Body>
</soap:Envelope>

 

The following XPath expression matches the Buf element regardless of the namespaces or prefixes:

/*/*/*/*[local-name()='Buf']

 

Notes

  • You'll need to manually enter the expression in the Element field.
  • First select a node and click apply, then customize the field with your expression.
  • There may be complications and adjustments to the XPath required if there are multiple nodes at the same level, etc.
Have more questions? Submit a request

0 Comments

Article is closed for comments.