xmlElementAttributes()

Returns all node attributes as a mapping.

Synopsis

mapping xmlElementAttributes(unsigned doc, unsigned node);

Parameters

Parameter Description
doc The document ID returned by e.g. xmlNewDocument().
node Node ID

Description

Returns all node attributes as a mapping, where the index is the attribute name and the value is the attribute's value.

Example

Reads the d:/XmlTest0.xml file and creates a document. The content of the document is printed using printNodes. The function xmlElementAttributes returns all node attributes as a mapping.

#uses "CtrlXml"
global uint docNum;
global string err;
global int errLine, errColumn;
main()
{
  uint node;
  DebugN(docNum = xmlDocumentFromFile("d:/XmlTest0.xml", err,
  errLine,
  errColumn));
  DebugN("error:", err, errLine, errColumn);
  printNodes(node = xmlFirstChild(docNum)); 
  xmlSetElementAttribute(docNum, node, "test_attribute", "some
  fancy 
  value !!");
}
void printNodes(int node)
{
  if ( node != -1 )
  {
    if ( xmlNodeType(docNum, node) == XML_TEXT_NODE )
    DebugN("value:", xmlNodeValue(docNum, node));
    if ( xmlNodeType(docNum, node) == XML_ELEMENT_NODE )
    DebugN(xmlNodeName(docNum, node), xmlElementAttributes(docNum,
    node) );
    printNodes(xmlFirstChild(docNum, node));
    printNodes(xmlNextSibling(docNum, node));
    DebugN(xmlDocumentFromFile(docNum, "d:/XmlTest0.xml",err,
    errLine,
    errColumn));
  }
}

Assignment

XML Control Extension

Availability

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