AddComment method: XmlNode class
Syntax
AddComment(Text)
Description
Use the AddComment method to add a comment to an XmlNode. The new attribute is appended to the list of child nodes.
To insert a comment at a particular place in the list of nodes, use the InsertComment method instead.
A reference to the newly created comment is returned.
Parameters
| Parameter | Description |
|---|---|
|
Text |
Specify the text to be used as the comment, as a string. |
Returns
A reference to the newly created comment.
Example
For example:
Local XmlDoc &inXMLDoc;
Local XmlNode &childNode;
Local XmlNode &commentNode;
&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><myroot/>");
&childNode = &inXMLDoc.DocumentElement.AddElement("child");
&commentNode = &childNode.AddComment("This is an example of a comment.");
The preceding PeopleCode program produces the following XML:
<?xml version="1.0"?>
<myroot>
<child>
<!--This is an example of a comment.-->
</child>
</myroot>
Related Topics