HOME

XML DOM Tutorial
DOM HOME
DOM Introduction
DOM Parsing
DOM ParseError
DOM Validator
DOM Access
DOM HttpRequest
DOM NodeType

XML DOM Objects
DOM Node
DOM NodeList
DOM Document
DOM Element
DOM Attr
DOM Text
DOM CDATA
DOM Comment

Examples
DOM Examples
Proposal Kit
Please visit our sponsors !

DOM - The Document object

prev next
Take a look at the XML file used in the examples: note.xml

Examples

documentElement
How to return the node name of the root element.

createCDATASection
How to create a CDATA node and then append it to the nodeList.

createComment
How to create a comment node and then append it to the nodeList.

createElement
How to create an element and then append it to the nodeList.

createTextNode
How to create a text node then append the text node to the nodeList.

getElementsByTagName
How to return the value of a specified node.


The Document object

The document object is the root element in the node tree. All nodes in the node tree are childNodes of the document element. The document element is required in all XML documents. The properties and methods of the Document object are listed below:

W3C Properties

Property Description
documentElement Returns the root element of the document
doctype Returns the DTD or Schema for the document. 
implementation Returns the implementation object for this particular document

W3C Methods

Method Description
createAttribute(attributeName) Creates an attribute node with the specified attribute name
createCDATASection(text) Creates a CDATASection, containing the specified text
createComment(text) Creates a comment node, containing the specified text
createDocumentFragment() Creates an empty documentFragment object
createElement(tagName) Creates an element with the specified tagName
createEntityReference(referenceName) Creates an entityReference with the specified referenceName
createProcessingInstruction(target,text) Creates a processingInstruction node, containing the specified target and text
createTextNode(text) Creates a text node, containing the specified text
getElementsByTagName(tagName) Returns the specified node, and all its child nodes, as a nodeList


prev next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

Domain Name Registration
Domain Name
Registration & More!



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search