XML Input String

The XML input string can be a literal string containing XML data. For example:

"XML=<employee>JohnSmith</employee>

Alternatively, the XML string can be a parameter containing the XML data. For example:

"XML={EmployeeNameParam}"

If the XML does not contain an XML encoding attribute, the LoadRunner XML parser uses UTF-8. If the input string contains an sequence that is not valid UTF-8, the script fails.

There are two options for handling invalid UTF-8.

  • Include an XML declaration with the appropriate encoding attribute. For example: <?xml version="1.0" encoding="ISO-8859-1"?>

  • Escape invalid UTF-8 hexadecimal characters. For example, it the input contains ,\xe6rre escape it by adding an additional back-slash: \\xe6rre

Example of escaped XML

XML=<employee id=\"1\"><name>John Smith</name><profession>scientist\\xenobiologist</profession></employee>

Example of fixing an XML returned from a server

char text_buffer[10000];

strcpy(text_buffer, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");

strcat(text_buffer, xml_input);

lr_save_string(text_buffer, "Param_errorList")