I'm wondering if it's possible to parse the poorly formed XML with the doSelectReturn below?
<doSelectResponse xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk"><doSelectReturn xmlns=""><?xml version="1.0" encoding="UTF-8"?><UDSObjectList><UDSObject><Handle>cnt:B89C91520C3C2044A3F07140A8F91CF8</Handle><Attributes><Attribute DataType="2002"><AttrName>last_name</AttrName><AttrValue>Communications</AttrValue></Attribute></Attributes></UDSObject></UDSObjectList></doSelectReturn></doSelectResponse>
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 < and > with < and > i could get an online parser to give me the values.
Is there another way to parse this xml within PAM that I'm not aware of?
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?
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):
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.text__ field where only the value should be?
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.text_;
Process.myUDSOs = applyXPath(Process.myCrStr, "//UDSObject", false, true);
Process.udso_0 = Process.myUDSOs;
Process.persistent_id = applyXPath(Process.udso_0,"//AttrName[text() = 'persistent_id']/../AttrValue/text()" );
I was able to figure out how to parse the xml using your example.
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.
Take for example, the createRequestReturn (below) returned by the Create Request operator (which incidentally does not have built in results parsing)
The entire Soap Response Body can be passed to the 'convertXml' function which will properly format the xml (replacing all the '<' and '>') so it can then be parsed with the 'applyXPath' operator.
See the post-execution code below which returns the extracted values.
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.