Expand my Community achievements bar.

How to read xml data using domelement

Avatar

Level 1

I have created SOAP service in Adobe campaign and passing XML data. In the schema I have created a method and have defined the param type as DOMElement. When I pass the xml data to the SOAP API I am not able to read/parse the xml data in js.

2 Replies

Avatar

Community Advisor

Hi @samirghogale 

it could be that you are passing a string and not a DOM object.

In that case try this in JS var input = DOMDocument.fromXMLString(data);

 

Cheers

Milan

Avatar

Level 1

I have defined the column xmlPayload as DOMElement in the schema testschema as below.

 

<methods>
<method library="tst:javaScript.js" name="methodname" static="true">
<parameters>
<param desc="schemaname" inout="in" name="xmlPayload" type="DOMElement"/>
<param desc="Return" inout="out" name="response" type="DOMElement"/>
</parameters>
</method>
</methods>

 

In the tst:javaScript.js script I have defined function tst_testschema_methodname(xmlPayload)

{

    var column1 = xmlPayload.body.addrress;

     logInfo(column1);

}

 

I dont see any value in column1.

 

My payload is 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
     <methodname>
       <sessiontoken>tokenstring</sessiontoken>
           <xmlPayload>
              <body>
                 <custname>Samir</custname>
                 <address>Mumbai</address>
              </body>
           </xmlPayload>
      </methodname>
   </soap:Body>
</soap:Envelope>

 

I need to see Mumbai