Gets the parent of specified node. If specified node is the root node in the tree, the parent is the document node.
Syntax
INT XMLGetParent(INT hDoc, INT hNode)
hDoc
Handle of the XML document. Returned by XMLCreate or XMLOpen.
hNode
Handle of the node. Returned by XMLGetRoot, XMLGetChild, XMLGetParent or XMLNodeFind.
Return Value
Handle of parent node, or error will be returned
Related Functions
XMLClose, XMLCreate, XMLGetAttribute, XMLGetAttributeCount, XMLGetAttributeName, XMLGetAttributeValue, XMLGetChild, XMLGetChildCount, XMLGetRoot, XMLNodeAddChild, XMLNodeFind, XMLNodeGetName, XMLNodeGetValue, XMLNodeRemove, XMLNodeSetValue, XMLOpen, XMLSave, XMLSetAttribute
Example
Following example creates an XML document from local file "H:\Data\books.xml", then selects the first node that matchs XPath expression "/bookstore/book/", then gets the parent of the node.
INT hDoc, hNode, hParent; hDoc=XMLOpen("H:\Data\books.xml"); If hDoc <> -1 THEN hNode=XMLNodeFind(hDoc,"/bookstore/book/");
IF hNode <> -1 THEN hParent=XMLGetParent(hDoc, hNode); End End
See Also
Published June 2018