XmlSetContent Function

Sets content for a node.

Usage

result = XmlSetContent(node_id)

Input Parameters

node_id—Handle returned by XmlEvaluate or XmlNewNode.

Returned Value

result—The node ID passed in is returned in the result or –1 if an error occurred.

Keywords

content—A string containing the content for the node.

new—Appends to the existing content of the given node. XmlSetContent will replace the content of a node if the new keyword is not used.

remove—If set removes the content carried by a node.

Discussion

XmlSetContent appends or replaces the text content of an XML node. The content must be a string. If you are creating a new node using XmlNewNode there is a keyword to set the content, so typically you would only use XmlSetContent to modify existing nodes in a document.

Example

This example makes use of the XmlEvaluate function to get the node_id and replaces the node content.

; Builds a DOM tree and returns its handle in doc_id.
; Note: The XPATH syntax of "//Attribute[@name='Title']" means
; select all 'Attribute' elements, which have an attribute name
; with value 'Title'.  In this case the resulting table will
; only have one row.
xml_init
doc_id = XmlParse('xml-1_0/data/chart.xml', /File)
; Creates a wave table.
table = XmlEvaluate(doc_id, "//Attribute[@name='Title']")
; Gets the node_id array from the table.
node_ids = table.nodeid
; Changes the content of the first node.
result = XmlSetContent(node_ids(0), Content='My New Title')