InsertComment method: XmlNode class
Syntax
InsertComment(Data, Position)
Description
Use the InsertComment method to insert a comment in an XmlNode at the location specified by Position.
Parameters
| Parameter | Description |
|---|---|
|
Data |
Specify the data for the comment as a string. |
|
Position |
Specify where you want to insert the comment, as a number. |
Returns
A reference to the newly created comment.
Example
For example:
Local XmlDoc &inXMLDoc;
Local XmlNode &dataNode;
Local XmlNode &commentNode;
&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><root/>");
&dataNode = &inXMLDoc.DocumentElement.AddElement("data");
&commentNode = &dataNode.AddComment("this is a comment");
&commentNode = &dataNode.AddComment("still another comment");
&commentNode = &dataNode.InsertComment("more comments", 2);
This is the XML document before the insert:
<?xml version="1.0"?>
<root>
<data>
<!--this is a comment-->
<!--still another comment-->
</data>
</root>
This is the XML document after the insert:
<?xml version="1.0"?>
<root>
<data>
<!--this is a comment-->
<!--more comments-->
<!--still another comment-->
</data>
</root>
Related Topics