Name
createComment: data
Synopsis
This returns a new Comment
node containing the specified
string. See the Comment object
reference earlier in this chapter for special restrictions that
apply to the contents of Comment
nodes.
Argument
- data: DOMString
The comment text.
Comment text restriction
The XML specification indicates that the --
characters must not appear in the
comment text for compatibility reasons. Despite this warning, some
DOM implementations don’t flag comments containing double hyphens
as syntax errors.
Java binding
public Comment createComment(String data);
Java example
// Create a timestamp comment StringBuffer sb = new StringBuffer( ); Date dtNow = new Date( ); sb.append("\tModified " + dtNow.toString( ) + '\n'); Comment cmt = doc.createComment(sb.toString( ));
Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.