KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Tips for validating XML using DOM Parse XML SOURCE
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: August 8, 2013

4D command DOM Parse XML SOURCE allows developers to parse XML structures to return the reference of the document. The second parameter for DOM Parse XML SOURCE is a boolean that is required if the XML structure needs to be validated. The command validates the XML structure using a DTD or XSD that is referenced in the XML structure or by using a third parameter with the command.

Example for using third parameter to validate XML structure:

$xml_Structure_Ref:=DOM Parse XML SOURCE("C:\\file.xml";True;"C:\\file.xsd")


The third parameter is not used if the XML structure is using a reference for validating in the document.

Example validating using reference in the XML structure:

$xml_Structure_Ref:=DOM Parse XML SOURCE("C:\\file.xml";True)


In the next example, Online XML validation will not give an error using the "schemaLocation" with just the file name, but 4D will give an error -9935 "The XML file is not valid or is not well-formed".

Example using just the schema file name in XML structure:

< xsi:schemaLocation="file.xsd" />


If the full path name to the schema file is used (example below), the XML structure will validate in 4D:

< xsi:schemaLocation="C:\\file.xsd" />