IT Process Automation

 View Only
  • 1.  Parse XML response from doSelect

    Posted Jul 11, 2018 04:00 PM

    I'm wondering if it's possible to parse the poorly formed XML with the doSelectReturn below?


    <doSelectResponse xmlns="">
    <doSelectReturn xmlns="">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;UDSObjectList&gt;
    &lt;Attribute DataType="2002"&gt;


    I've tried using the applyXPath operator and I can get it to parse the doSelectResponse and give me the doSelectReturn but I can't get it to return any values within the doSelectReturn. I assume this behavior is due to poorly formed xml because once i replaced &lt; and &gt with < and > i could get an online parser to give me the values.

    I tried to do the same thing with JavaScript in PAM   .....replace(/&lt;/g, '<').replace(/&gt;/g, '>'); but I still couldn't get PAM to return any values.


    Is there another way to parse this xml within PAM that I'm not aware of?



  • 2.  Re: Parse XML response from doSelect

    Posted Jul 11, 2018 06:00 PM
    1. In the Call Result tab of the SOAP operator, check the box for "Extract SOAP response body first-level elements to individual Dataset variables". This will populate an operator ValueMap variable named Process[OpName].SoapResponseData
    2. In your Post Execution you can now reference the XML as Process[OpName].SoapResponseData.doSelectReturn[0].text__

  • 3.  Re: Parse XML response from doSelect

    Posted Jul 16, 2018 03:08 PM

    I'm using PAM 4.3 SP01  and SD 14.1 and below is the result I get when I check the box you mentioned.


    I get the same results when I check other boxes that I would expect should help extract the values.


    Can you verify the versions of PAM and SD you're getting the expected results on?



  • 4.  Re: Parse XML response from doSelect

    Posted Jul 16, 2018 04:22 PM

    In your SOAP call, what are you putting between <attributes> and </attributes>?

    My guess is that you are putting <string>persistent_id</string> because that is what is being returned.

    If you want all attributes for an object to be returned then leave the space between <attributes> and </attributes> empty.

    If you want specific attributes then put something like this (using pcat as an example):


  • 5.  Re: Parse XML response from doSelect

    Posted Jul 17, 2018 09:09 AM

    The persistent_id is the only attribute I need, the issue I face now is how do I parse the xml that's returned in the Process[OpName].SoapResponseData.doSelectReturn[0].text__  field where only the value should be?

  • 6.  Re: Parse XML response from doSelect
    Best Answer

    Posted Jul 18, 2018 02:39 AM

    Hi Elwynn,


    I would normally do something along these lines, first extracting the 'UDSObjects' into an array and then applying XPath against each UDSObject.  In your case there will only be one 'UDSObject' returned but the approach still works.


    Process.myCRStr = Process[OpName].SoapResponseData.doSelectReturn[0].text_;

    Process.myUDSOs = applyXPath(Process.myCrStr, "//UDSObject", false, true);


    Process.udso_0 = Process.myUDSOs[0];


    Process.persistent_id = applyXPath(Process.udso_0,"//AttrName[text() = 'persistent_id']/../AttrValue/text()" );





  • 7.  Re: Parse XML response from doSelect

    Posted Jul 18, 2018 03:14 PM

    Thanks James!   

    I was able to figure out how to parse the xml using your example.


  • 8.  Re: Parse XML response from doSelect

    Posted Nov 09, 2018 01:13 PM

    I found the answer to the problem of how to parse poorly formed xml returned from SD in PAM. The answer lies in the 'convertXml' system function. While some operators include built in xml parsing, some don't which creates extra challenges.


    results xml parsing


    Take for example, the createRequestReturn (below) returned by the Create Request operator (which incidentally does not have built in results parsing)

    create Request Return


    The entire Soap Response Body can be passed to the 'convertXml' function which will properly format the xml (replacing all the '&lt;' and '&gt;') so it can then be parsed with the 'applyXPath' operator.


    See the post-execution code below which returns the extracted values.

    post exec. code Line 7 does the conversion, line 8 strips away the envelope, etc... and lines 9-11 return the actual values.

    Note: line 8 is returning an array of attributes while 9 -11 are only returning strings due to the second flag in the applyXPath function.