xmlSetNodeValue()

Sets the node's value to the given value.

Synopsis

int xmlSetNodeValue(unsigned doc, unsigned node, string value);

Parameters

Parameter Description
doc The document ID returned by e.g. xmlNewDocument().
node Node name (ID)
value New value of the node

Description

Sets the node's value to the given value.

The meaning of the value depends on the node type that is asked.

The following node type constants are here meaningful:

Constant Meaning
XML_ATTRIBUTE_NODE Attribute value
XML_CDATA_SECTION_NODE Content of the CDATA section
XML_COMMENT_NODE Comment
XML_PROCESSING_INSTRUCTION_NODE Data of the processing instruction
XML_TEXT_NODE Text

All the other node types do not have a node value and will return an empty string.

Example

This example creates a new document in memory and adds nodes to the document. It also sets attributes,

sets a node value and prints the content of the document.

#uses "CtrlXml"
main()
{
  int docNum = xmlNewDocument();
  xmlAppendChild(docNum, -1, XML_COMMENT_NODE, "my fine new
  comment");
  int node = xmlAppendChild(docNum, -1, XML_ELEMENT_NODE, "first
  element");
  node = xmlAppendChild(docNum, node, XML_ELEMENT_NODE,
  "sub_element");
  xmlSetElementAttribute(docNum, node, "anAttribute", "a
  value");
  node = xmlAppendChild(docNum, node, XML_TEXT_NODE, "some
  text");
  xmlSetNodeValue(docNum, node, "The new value");
  DebugN(xmlDocumentToString(docNum));
}

Assignment

XML Control Extension

Availability

CTRL. In every script where the "CtrlXml" extension (#uses "CtrlXml") is used.