IT Process Automation

 View Only
  • 1.  Parsing XML return for Properties

    Posted Jul 24, 2015 11:20 AM

    I am trying to parse the return of a getRelatedListValues that returns the Properties for a request. I get the XML below from the query and I tried using applyXPath as follows:

     

    Process.getPropertiesResult = applyXPath(Process[OpName].SoapResponseData.getRelatedListValuesResult[0].text_, "//Attribute[AttrName='value']/AttrValue/text()")

     

    Unfortunately, this results in a single string with ALL the 'value' results contained in that one string, i.e. "GeneralUseJim BeacherNo"...etc.

    Do I need to store this result in an array? How do I get each 'value' return in it's own variable?

     

     

    <?xml version="1.0" encoding="UTF-8"?>

    <UDSObjectList>

    <UDSObject>

    <Handle>cr_prp:401551</Handle>

    <Attributes>

    <Attribute DataType="2002">

    <AttrName>value</AttrName>

    <AttrValue>General Use</AttrValue>

    </Attribute>

    </Attributes>

    </UDSObject>

    <UDSObject>

    <Handle>cr_prp:401552</Handle>

    <Attributes>

    <Attribute DataType="2002">

    <AttrName>value</AttrName>

    <AttrValue>Jim Beacher</AttrValue>

    </Attribute>

    </Attributes>

    </UDSObject>

    <UDSObject>

    <Handle>cr_prp:401553</Handle>

    <Attributes>

    <Attribute DataType="2002">

    <AttrName>value</AttrName>

    <AttrValue>No</AttrValue>

    </Attribute>

    </Attributes>

    </UDSObject>

    <UDSObject>



  • 2.  Re: Parsing XML return for Properties

    Broadcom Employee
    Posted Jul 28, 2015 09:16 AM

    In the operator properties in PAM there is a "Call Results" tab and at the bottom of that is the "Additional Extracted Data" section where you can enter multiple XPath expressions and assign them to dataset variables.  (Perhaps this is what you are already doing).

     

    I found this online to help with XPath Syntax:  XPath Syntax

     

    I think the problem with your Syntax is that you are telling it to put all values in 1 variable and that sounds like it is what you are getting back.  In the above page I found online, they give you the syntax for using an index to specify the first attribute only and then the second attribute only.  Hopefully this will help.



  • 3.  Re: Parsing XML return for Properties

    Posted Jul 29, 2015 04:11 PM

    Try the convertXml function

     

    Process.getPropertiesCount = Number(Process[OpName].SoapResponseData.numRowsFound[0].text_);

    Process.getPropertiesResult = convertXml(Process[OpName].SoapResponseData.getRelatedListValuesResult[0].text_);



  • 4.  Re: Parsing XML return for Properties

    Posted Jul 29, 2015 09:49 PM

    Hi Greg,

     

    look at the documentation for the 'applyXPath' system function - you can pass additional flags that specify to strip the namespace and return an array - something like this:

     

    var myProps = [];

    // Get an array of Attribute values

    myProps = applyXPath(Process[OpName].SoapResponseData.getRelatedListValuesResult[0].text_, "//Attribute[AttrName='value']/AttrValue/text()", false, true);


    Hope that helps!

    Regards,

    James