xmlParentNode()
Returns the internal ID for the parent node of the given node.
Synopsis
int xmlParentNode(unsigned doc, unsigned node);
Parameters
| Parameter | Description | 
|---|---|
| doc | The document ID returned by e.g. xmlNewDocument(). | 
| node | Node for whose parent node the internal ID should be returned. | 
Return value
Internal ID for the parent node of the given node.
It returns -1 it the node does not exist.
Description
Returns the internal ID for the parent node of the given node.
 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. XmlNextSibling is used to return the internal Id of the next sibling of a node. XmlNodeName returns the name of a node. XmlNodeType returns the type of the given node. xmlParentNode returns the internal ID for the parent node of the given node.
#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));
    printNodes(xmlParentNode(docNum, node));
    DebugN(xmlDocumentFromFile(docNum, "d:/XmlTest0.xml",err,
    errLine,
    errColumn));
  }
}
        Assignment
Availability
CTRL. In every script where the "CtrlXml" extension (#uses "CtrlXml") is used.