xmlSetElementAttribute()

Sets the attribute of a node to given value.

Synopsis

int xmlSetElementAttribute(unsigned doc, unsigned node, string attr, string value);

Parameters

Parameter Description
doc The document ID returned by e.g. xmlNewDocument().
node Node ID
attr Attribute which value shall be set.
value New value of the attribute

Return value

0 if the value has been set successfully.

If an error occurs, -1 will be returned.

Description

Sets the attribute of a node to given value.

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.