Expand my Community achievements bar.

how do i Convert XML item to a List variable in adobe LC

Avatar

Level 7

Hi,

I am producing an xml document from the adobe livecycle process and getting below data in document. I want to map each index item in a List<int> variable in adobe lc process.

ListIndex1<int>={1,1,1,1,1}

ListIndex3<string>={CoreTC,State 14.01,State 14.02,State 14.04,Vehicle Info, Used Plan}.

I know i can map xml document variable with an schema and access each index not. but not able to prepare List.

<RootElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">1</Index2>

        <Index3 type="varchar">CoreTC</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

     </rElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">2</Index2>

        <Index3 type="varchar">State 14.01</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

    </rElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">3</Index2>

        <Index3 type="varchar">State 14.02</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

    </rElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">4</Index2>

        <Index3 type="varchar">State 14.04</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

     </rElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">501</Index2>

        <Index3 type="varchar">Vehicle Info</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

    </rElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">502</Index2>

        <Index3 type="varchar">New Plan</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

    </rElement>

    <rElement>

        <Index1 type="int">1</Index1>

        <Index2 type="int">503</Index2>

        <Index3 type="varchar">Used Plan</Index3>

        <Index4 type="varchar">c:\tmp</Index4>

        <Index5 type="float">1.0</Index5>

    </rElement>

</RootElement>

Regards

Sunil Gupta

1 Reply

Avatar

Former Community Member

Here is the we can create a list out of XML data

count the number of elements using

  count(/process_data/xmlData/RootElement/rElement)

write script element as follows to access xml element data

int intCount=patExecContext.getProcessDataIntValue("/process_data/@intCount");
String elementName=patExecContext.getProcessDataStringValue("/process_data/@ElementName");
String rootElementString="/process_data/xmlData/RootElement/rElement["+intCount+"]/"+elementName;

String elementValue=patExecContext.getProcessDataStringValue(rootElementString);

patExecContext.setProcessDataStringValue("/process_data/@outTestString",elementValue);

using setValue in the process XPath mapping map

/process_data/@outTestString to /process_data/listVariableOut[number(/process_data/@intCount)] 

listVariableOut is List of strings of elementValue. loop above code for all the elements, to get a list of element values

Here is the process diagram you can use as guidance

XMLDataToListProcess.jpg