Expand my Community achievements bar.

Execute Script to read XML variable

Avatar

Level 7

How is it possible to read from XML variable? I tried using

patExecContext.getProcessDataDocumentValue

patExecContext.getProcessDataValue

and it didn't work. Can someone please help

Aditya

5 Replies

Avatar

Level 8

maybe try getProcessDataStringValue?

Avatar

Level 7

It removes the XML tags.

XML Value

<form1>
    <Details>
        <review_from type="VARCHAR">06292009</review_from>
        <review_to type="VARCHAR">06282010</review_to>
        <site_name type="VARCHAR">General Electric Office, Schenectady</site_name>
        <site_street type="VARCHAR">1 River Road</site_street>
      </Details>
</form1>

Resultant Value

        06292009
        06282010
        General Electric Office, Schenectady
        1 River Road

Aditya

Avatar

Former Community Member

Try 'getProcessDataValue'.

I did a little test with two process variables

1) xmlData - variable type 'xml'

2) xmlStr - variable type 'string'

and two services

1) Set Value

/process_data/@xmlStr <> serialize(/process_data/xmlData)

2) Custom Script

String xmlStr = patExecContext.getProcessDataValue("/process_data/xmlStr");

patExecContext.setProcessDataValue("/process_data/xmlData",xmlStr);

where the value of xmlStr was

<form1>

    <Details>

        <review_from type="VARCHAR">06292009</review_from>

        <review_to type="VARCHAR">06282010</review_to>

        <site_name type="VARCHAR">General Electric Office, Schenectady</site_name>

        <site_street type="VARCHAR">1 River Road</site_street>

    </Details>

</form1>

and the resulting value of xmlData was

<form1>

    <Details>

        <review_from type="VARCHAR">06292009</review_from>

        <review_to type="VARCHAR">06282010</review_to>

        <site_name type="VARCHAR">General Electric Office, Schenectady</site_name>

        <site_street type="VARCHAR">1 River Road</site_street>

    </Details>

</form1>

Steve

Avatar

Level 7

Are the two services different ways of doing the same thing? Or, you assign the xmldata to xmlstr using setValue and then assign the string value back to xmldata.

Aditya

Avatar

Former Community Member

I wanted to go through the exercise of passing XML and an XML string through patExecContext.