DOM Parse XML variable

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 2004 (Modified)


DOM Parse XML variable (variable{; validation{; dtd}}) String

ParameterTypeDescription
variableBLOB/TextName of the variable
validationBooleanTrue = Validation by the DTD,
False = No validation
dtdStringLocation of the DTD
Function resultStringReference of XML element (16 characters)

Description

The DOM Parse XML variable command parses a BLOB or Text type variable containing an XML structure and returns a reference for this variable. The command can validate (or not) the document.

Pass the name of the BLOB or Text variable containing the XML object in the variable parameter.

The Boolean parameter validation is used to indicate whether or not to validate the structure using the DTD.

If validation equals True, the structure will be validated. In this case, the parser will attempt to validate the XML structure of the document based either on the DTD defined or referred to in the document, or that designated by the dtd parameter.

If validation equals False, the structure will not be validated.

The third parameter, dtd, is used to indicate the specific DTD for document parsing. If you use this parameter, the command will not take the DTD referred to in the XML variable into account.

There are two ways to specify a DTD:

as a reference. To do this, pass the complete pathname of the new DTD in the dtd parameter. If the document indicated does not contain a valid DTD, the dtd parameter is ignored and an error is generated.

directly in text. In this case, if the contents of the parameter begin with "<?xml", 4D will consider that it is the DTD; otherwise, 4D will consider it as a pathname.

If validation cannot be performed (no DTD, incorrect URL to DTD, etc.), an error is generated. The Error system variable indicates the error number. You can intercept this error using a method installed by the ON ERR CALL command.

The command returns a 16-character string (ElementRef) making up the reference in the memory of the document virtual structure. This reference should be used with other XML parsing commands.

Important: Once you no longer have any need for it, remember to call the DOM CLOSE XML command with this reference in order to free up the memory.

Examples

1. Opening an XML object located in a 4D Text variable, without validation:

   C_TEXT(myTextVar)
   C_TIME(vDoc) 
   C_STRING(16;$xml_Struct_Ref)

   vDoc:=Open document ("Document.xml")
   If (OK=1)
      RECEIVE PACKET(vDoc;myTextVar;32000)
      CLOSE DOCUMENT(vDoc)
      $xml_Struct_Ref:=DOM Parse XML variable(myTextVar)
   End if

2. Opening an XML document located in a 4D BLOB, without validation:

   C_BLOB(myBlobVar)
   C_STRING(16;$ref_XML_Struct)

   DOCUMENT TO BLOB("c:\\import.xml";myBlobVar)
   $xml_Struct_Ref:=DOM Parse XML variable(myBlobVar)

See Also

DOM CLOSE XML, DOM Parse XML source.

System Variables or Sets

If the command has been correctly executed, the system variable OK is set to 1. Otherwise, it is set to 0.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next