JavaScript Functions > Alphabetical Listing of Utility Functions (lr) > lr.xmlGetValues

lr.xmlGetValues

Retrieves values of XML elements found by a query.

Example XML Functions (LR_XML)

Syntax

lr.xmlGetValues( {object} );

JavaScript Object

{
   xml:"<string>",
   valueParam:"<string>",
   query:"<string>", | fastQuery:"<string>",
   selectAll:"<string>",
   notFound:"<string>"
} 
Property Name
Description
xml The XML Input String to query.
valueParam The name of the output parameter which stores the result of the query. If it does not exist, it is created.
query The XML Query on the input string XML. You can specify elements or attributes.
fastQuery The Fast Query on the input string XML. You can specify elements or attributes.
valueParam The name of the parameter containing the value to set as the XML element.
selectAll If "yes", all elements matching the query will be processed. If "no", only the first match will be processed. Default is "no". See Multiple Query Matching.
notFound See Continuing on Error.

The lr.xmlGetValues function queries the XML input string XML for values matching the Query criteria.

Return Values

All XML functions return the number of matches successfully found or zero on failure.

Parameterization

Input parameters to XML functions with the following names can be parameterized:

Example

 

function Action(){
   var xml_input =

   "<acme_org>"+
       " <accounts_dept>"+
           "<employee>"+
               " <name>John Smith</name>"+
               "<cubicle>227</cubicle>"+
               "<extension>2145</extension>"+
           "</employee>"+
       "</accounts_dept>"+
       "<engineering_dept>"+
           "<employee>"+
               "<name>Sue Jones</name>"+
               "<extension>2375</extension>"+
           "</employee>"+
       "</engineering_dept>"+
   "</acme_org>";


       var i, numOfValues;

       lr.saveString(xml_input, "XML_Input_Param"); // Save input as parameter
       lr.saveString("1111","ExtensionParam_1");
       lr.saveString("2222", "ExtensionParam_2");

       lr.xmlSetValues({xml:"{XML_Input_Param}",
        resultParam:"NewXmlParam", 
        valueParam:"ExtensionParam",
        selectAll:"yes",
        query:"//extension"
      });


       numOfValues= lr.xmlGetValues({xml:"{NewXmlParam}",
        valueParam:"OutputParam",
        query:"//extension",
        selectAll:"yes"});


       for ( i = 0; i < numOfValues; i++) { /* Print the multiple values of MultiParam */

           var buf = "Retrieved value "+ (i+1) +" : {OutputParam_}" + (i+1);
           

           lr.outputMessage(lr.evalString(buf));

       }


return 0;
}