Click to return to the XML (Extensible Markup Language) home page    
XMLDOMDocument doctype Pr...     XMLDOMDocument getElement...     XMLDOMDocument Object    
Web Workshop  |  XML (Extensible Markup Language)

documentElement Property


Contains the root element of the document.

Syntax

objXMLDOMElement = oXMLDOMDocument.documentElement
objXMLDOMDocument.documentElement = objXMLDOMElement 

Remarks

Object. The property is read/write. It returns the XMLDOMElement object that represents the single element that represents the root of the XML document tree. It returns NULL if no root exists.

When setting the documentElement property, the specified element node is inserted into the child list of the document after any document type node. To precisely place the node within the children of the document, call the XMLDOMNode object's insertBefore method.

The parentNode property is reset to the document node as a result of this operation.

Example

The following example creates an XMLDOMElement object and sets it to the root element of the document with the documentElement property. It then walks the document tree:

Dim root
Dim xmlDoc

Set xmlDoc = CreateObject("microsoft.xmldom")
xmlDoc.async = False
xmlDoc.load("c:\books.xml")
Set root = xmlDoc.documentElement
For i = 0 To (root.childNodes.length -1)
  MsgBox (root.childNodes.item(i).childNodes.item(0).text)
Next

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
XMLDOMDocument


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.