Please enable JavaScript to view this site.

ESL Documentation

Navigation: » No topics above this level «

Q9. How do I parse an XML data string?

Scroll Prev Top Next More

Whilst the standard for most web pages is the Hyper Text Mark-up Language (HTML) a similar standard has developed for the transmission of structured data within a string. This standard is known as eXtended Mark-up Language or XML. As with HTML, information is grouped using opening and closing tags, which make the parsing of the data comparatively simple using ESL built-in “extract” statement, as the following routine demonstrates:

FAQs_WebAccess_Q9_1

The problem with the above routine is that the XML standard allows for multiple occurrences of a field whilst the routine can only return one occurrence, which will be the first. Consider the following structure:

FAQs_WebAccess_Q9_2

An Example of the above ESL Structure in XML might be:

FAQs_WebAccess_Q9_3

To enable the parsing of multiple address lines, we need to include a starting position, enabling a loop to be set-up to extract each occurrence, as in the following code:

FAQs_WebAccess_Q9_4

As the example Client structure includes an embedded Address structure, we recommend that the sub XML string is extracted before being parsed, to prevent any duplicate tag names that may occur when there are multiple embedded structures. Using the above routine the Client parse routine is:

FAQs_WebAccess_Q9_5