Hi All,
I need to extract namespace from a node to perform further operations. My XML is something like shown below.
<SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>...</SOAP-ENV:Header>
<SOAP-ENV:Body>
<CreateAndSendEnvelope xmlns="http://www.docusign.net/API/3.0">....</CreateAndSendEnvelope>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I need to extract namespace of CreateAndSendEnvelope node.
I used extract variable policy as shown below.
<XMLPayload>
<Namespaces>
<Namespace prefix="dir">http://schemas.xmlsoap.org/soap/envelope</Namespace>
</Namespaces>
<Variable name="operationname" type="string">
<XPath>/dir:Envelope/dir:Body/CreateAndSendEnvelope/@xmlns</XPath>
</Variable>
</XMLPayload>
Any help would be appreciated,
Thankyou
1 Like
Hi,
Can u try with this line:
<Namespaces>
<Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/encoding/</Namespace>
</Namespaces>
<Variable name="CreateAndSendEnvelope" type="string">
<XPath>/soapenv:Envelope/soapenv:Header/soapenv:Header:Body/CreateAndSendEnvelope</XPath>
</Variable>
hi, I can guess what the problem is, but YOU DIDNāT SAY IT.
You said āI need to extract namespace of CreateAndSendEnvelope node.ā
and āthis is the policy I usedā
andā¦
WHAT HAPPENED? What results did you see?
You didnāt say.
I will have to guess. I guess that you didnāt get the data extracted as you expected. Is that right?
Namespaces in XML are very specific. The namespace often looks like a web URI, and we may assume that
http://foo/bar/
is equivalent to
http://foo/bar (no trailing slash)
But that is not the case, when dealing with XML namespaces.
Specific to your case, you have
<Namespaces>
<Namespace prefix="dir">http://schemas.xmlsoap.org/soap/envelope</Namespace>
</Namespaces>
And thatās not good. The namespace you want ends with a slash.
Add the trailing slash:
<Namespaces>
<Namespace prefix="dir">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
</Namespaces>
But, two additional things.
- if I were doing this I would not use ādirā as a prefix. Itās true that the prefix is not semantically important. Itās just a variable name. But as with regular programming code, there are good and bad variable names. When an xml namespace refers to the soap encoding namespace, the prefix used is often āsoapā. Or at the very least, āsā. That tells people what you intend.
- You canāt get the xmlns via an attribute. you need to use the namespace-uri function
The result of these three changes like this:
<XMLPayload>
<Namespaces>
<!-- note the trailing slash here -->
<Namespace prefix="s">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
</Namespaces>
<Variable name="operationname" type="string">
<XPath>local-name(/s:Envelope/s:Body/*)</XPath>
</Variable>
<Variable name="xmlns" type="string">
<XPath>namespace-uri(/s:Envelope/s:Body/*)</XPath>
</Variable>
</XMLPayload>
1 Like
Hi,
yes, I am unable to extract the value. operationname variable is Null