KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Beware of using DOM PARSE XML SOURCE with an HTTP source
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: July 11, 2013

Although the DOM PARSE XML SOURCE command can be used to parse an XML file that is hosted on an HTTP server, it is important to note that the call to DOM PARSE XML SOURCE is synchronous. Meaning that 4D will not move on until after the parsing is complete. This becomes an important fact when working with hosted XML files where a delay may happen.

Lets say for example, that a URL to be parsed with DOM PARSE XML SOURCE takes 45 seconds to return the response (this could be caused by poor network conditions, a large query, unforseen conditions on the server hosting the xml, etc) then 4D may seem frozen for that period of time.

It is because of this that it is recommended to use a command that is asynchronous such as HTTP GET to obtain the XML into a 4D variable, and then use DOM PARSE XML VARIABLE instead.

The following code:

$url:="https://some.webserver.com/that/takes/long/2respond.xml"
$xml:=DOM PARSE XML SOURCE($url)


Could become:
$url:="https://some.webserver.com/that/takes/long/2respond.xml"
$status:=HTTP GET($url;$response)
$xml:=DOM PARSE XML VARIABLE($response)


Using the HTTP GET command, which is designed for network operations like this, can overcome any possible network slowdown or freeze that may occur otherwise.