xmlIsSameNode()

Checks whether two node IDs are pointing to the same internal node within the DOM tree.

Synopsis

bool xmlIsSameNode(unsigned doc, unsigned node1, unsigned node2);

Parameters

Parameter Description
doc The document ID returned by e.g. xmlNewDocument().
node1, node2 Node IDs that shall be compared.

Return value

TRUE if the specified node IDs are pointing to the same internal node, otherwise FALSE.

Description

Checks whether two node IDs (received by any operation) are pointing to the same internal node within the DOM tree and returns 1 in case of the same internal node or 0 in case of different internal nodes.

Example

#uses "CtrlXml"
main()
{
  uint doc = xmlNewDocument();
  xmlAppendChild(doc, -1, XML_PROCESSING_INSTRUCTION_NODE,
  "xml version=\"1.0\" encoding=\"UTF-8\"");
  int root = xmlAppendChild(doc, -1, XML_ELEMENT_NODE,
  "test");
  xmlSetElementAttribute(doc, root, "anAttribute", "a value");
  int node1 = xmlAppendChild(doc, -1, XML_ELEMENT_NODE,
  "one");
  int node2 = xmlAppendChild(doc, -1, XML_ELEMENT_NODE,
  "two");
  //Check whether the 2 node IDs are pointing to the same internal
  node
  //Result should be 0
  DebugN(xmlIsSameNode(doc, node1, node2));
  node1 = xmlFirstChild(doc);
  node2 = xmlFirstChild(doc);
  //Result should be 1. Both node IDs are pointing to the same
  internal node
  //although the ID of node1 and node2 is different.
  DebugN(xmlIsSameNode(doc, node1, node2), node1, node2);
}

Assignment

XML Control Extension

Availability

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