XML DOM - Comment Object
- Previous page DOM CSSStyleSheet
- Next page DOM Document
The Comment object represents the content of the comment node in the document.
Example
In the following example, we will use the XML file books_comment.xml, as well as JavaScript functions loadXMLDoc().
Comment object
The Comment object represents the content of the comment node in the document.
The Comment node represents comments in HTML or XML documents.
using the one by CharacterData interfaceinherited data attributeor use the one inherited from the Node interface nodeValue attributeYou can access the content of comments. (That is, the text between <!-- and -->). Various methods inherited from the CharacterData interface can be used to manipulate the content of comments.
Usage Document.createComment() To create a comment object.
Comment object attribute
Attribute | Description | IE | F | O | W3C |
---|---|---|---|---|---|
data | Can set or return the text of this node. | 6 | 1 | 9 | Yes |
length | Can return the length of the text of this node. | 6 | 1 | 9 | Yes |
Comment object method
Method | Description | IE | F | O | W3C |
---|---|---|---|---|---|
appendData() | Append data to the node. | 6 | 1 | 9 | Yes |
deleteData() | Delete data from the node. | 6 | 1 | 9 | Yes |
insertData() | Insert data into the node. | 6 | 1 | 9 | Yes |
replaceData() | Replace data in the node. | 6 | 1 | 9 | Yes |
substringData() | Extract data from the node. | 6 | 1 | 9 | Yes |
Related pages
XML DOM Reference Manual:CharacterData object
- Previous page DOM CSSStyleSheet
- Next page DOM Document