XML Functions (LR_XML) > Defining the Parameter Set

Defining the Parameter Set

Parameter sets have the form:

Param_1, Param_2, Param_3, ...

where Param is the value either in argument "ValueParam=Param" or in "XmlFragmentParam=Param" .

For example, if the following argument is passed:


then the function will write the matches it finds into parameters:

multi_param_1, multi_param_2, multi_param_3 ...

With Functions that read a parameter set, the values written to the parameter can then be evaluated. For example, the following code retrieves (using lr_xml_get_values) and prints out (using lr_eval_string) multiple matches of a query:

NumOfValues = lr_xml_get_values("Xml={XmlParam}", "Query=//string",
           "SelectAll=yes", "ValueParam=MultiParam", LAST );

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

          char buf[1000];
          sprintf (buf, "Retrieved value %d : {MultiParam_%d}", i+1);

For Functions that write to a parameter set, the values of the parameter set must be pre-defined before the function can read from it. The parameter must also be named in the form:

Param_1, Param_2, Param_3, ...

where Param is the value in "Specification=Param".

For example, lr_xml_set_values reads each value from a parameter set and then sets that value in the XPath match returned by the query. The following code pre-defines a parameter set called "ExtensionParam", which has two members: ExtensionParam_1 and ExtensionParam_2. lr_xml_set_values then queries the XML input string and sets the value of the first match returned as "1111" and the second as "2222".

    lr_save_string("1111", "ExtensionParam_1");
     lr_save_string("2222", "ExtensionParam_2");

          "ResultParam=NewXmlParam", "ValueParam=ExtensionParam",
          "SelectAll=yes", "Query=//extension", LAST );