SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 22-11-2018 07:40:54

Registered: 20-11-2018
Posts: 148

How to collect an Attribute from an XML (esp. Web Service Response)

OK ... so there is no simple way to do this currently.

I had to get the "status" attribute from the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="">
    <ns2:processTransactionResponse xmlns:ns2="">
      <SXIReturn status="FAILED">
        <message>Failed to create XML file.</message>

however when I used the following XPath:


only the word status was returned .. however it worked in Oxygen (although it did return the full attribute >status="FAILED"<

The only way I have found so far to fetch an attribute is to address it via a stylesheet using an ApplyStyleSheetToMemoryContents mapping in XLayer using a simple stylesheet that looks as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
    <xsl:variable name="status" select="//*[local-name()='SXIReturn'][last()]/@status"/>
    <xsl:template match="@*|node()">
            <xsl:apply-templates />
        <xsl:if test="@status">
           <xsl:apply-templates select="@status" />
    <xsl:template match="@status">
        <SXIReturnStatus><xsl:value-of select="$status" /></SXIReturnStatus>

This copies all the xml but ALSO create a new xml element called "SXIReturnStatus" and adds the value of the status attribute to it.

This way I can run a "MemoryDataManipulation" mapping to see if the status was SUCCESS or FAILURE using a condition as follows:

<MemoryDataManipulation dataDefinition="GetSOAPStatus">
             <When field="//*[local-name()='MySoapStatus']" operator="Matches" value="FAILED">
                 <LogComment Comment="==== FAILED FAILED FAILED ====="/>


Board footer

Powered by FluxBB