4D v14.3

DOM Get XML document ref

Home

 
4D v14.3
DOM Get XML document ref

DOM Get XML document ref 


 

DOM Get XML document ref ( elementRef ) -> Function result 
Parameter Type   Description
elementRef  Text in Reference of existing element in DOM tree
Function result  Text in Reference of first element of a DOM tree (document node)

The DOM Get XML document ref command is used to recover the reference of the "document" element of the DOM tree whose reference you have passed in elementRef. The document element is the first element of a DOM tree; it is the parent of the root element. 

The reference of the document element lets you handle the "Doctype" and "Processing Instruction" nodes. It can only be used with the DOM Append XML child node and DOM GET XML CHILD NODES commands.

At this level, you can only append processing instructions and comments or replace the Doctype node. You cannot create CDATA or Text nodes there.

Example  

In this example, we want to find the DTD declaration of the XML document:

 C_TEXT($rootRef)
 $rootRef:=DOM Parse XML source("")
 If(OK=1)
    C_TEXT($documentRef)
  // we are looking for the document node, since it is the node to which
  // the DOCTYPE node is attached before the root node
    $documentRef:=DOM Get XML document ref($rootRef)
    ARRAY TEXT($typeArr;0)
    ARRAY TEXT($valueArr;0)
  // on this node we look for the DOCTYPE type node among the
  // child nodes
    DOM GET XML CHILD NODES($refDocument;$typeArr;$valueArr)
    C_TEXT($text)
    $text:=""
    $pos:=Find in array($typeArr;XML DOCTYPE)
    If($pos>-1)
  // We retrieve the DTD declaration in $text
       $text:=$text+"Doctype: "+$valueArr{$pos}+Char(Carriage return)
    End if
    DOM CLOSE XML($rootRef)
 End if

 
PROPERTIES 

Product: 4D
Theme: XML DOM
Number: 1088

 
HISTORY 

Created: 4D v12

 
SEE ALSO 

DOM Append XML child node
DOM GET XML CHILD NODES

 
ARTICLE USAGE

4D Language Reference ( 4D v12.4)
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v13.5)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)