XML Functions (LR_XML) > Continuing on Error

Continuing on Error

In cases where no value is found by a Query, you can use the NotFound parameter to control the consequent behavior of the script. The value of NotFound can be one of:

Error: the default value, causing an error and script execution to cease

Continue: execution continues, and no error is issued. A warning message is sent to the Execution Log window.


The following example attempts to insert an XML fragment into an XML string, but the query fails because it cannot find the tag /acme_org/department/employee. The script would terminate at this point if the default NotFound behavior of Error was in effect. However, the lr_xml_insert call specifies NotFound=Continue, and script execution continues to the next statement, lr_output_message.

#include "as_web.h"

char *xml_input =
          " <name>John Smith</name>"

Action() {

     lr_save_string(xml_input, "XML_Input_Param");

     lr_xml_insert("XML={XML_Input_Param}", "ResultParam=Result",
          "NotFound=Continue", LAST );

     lr_output_message("Reached here");

     return 0;

Action.c(15): Warning: "lr_xml_insert" found no matches
Action.c(21): Reached here