xmlNodePosition()
The function returns the position of a node inside of an XML document.
Synopsis
int xmlNodePosition(unsigned doc, unsigned node, int &line, int
&column);
Parameters
Parameter | Description |
---|---|
doc | The document ID |
node | Node ID |
line | line number in which the node is located |
column | column number in which the node is located |
Return value
On success the function returns 0 and -1 in case of an error.
Description
The function returns the line and column number of a specific node inside of an XML document. The XML document has to be loaded using the functions xmlDocumentFromFile() or xmlDocumentFromString(). If these functions are not used to load the XML document the line and column parameters return a value of -1.
The line is the position in which the node has been parsed within the XML document whereas the column represents the position of the last character in the node. Please note that the column position is based on a "best guess" and deviations might occur.
Example
Folowing example reads the XML file "myXML.xml" and returns the column and line of the first node within the XML document.
int Id;
string fileName = "D:/myXML.xml";
string errMsg;
int errLine, errColumn;
int line,col;
int i;
uint node;
Id = xmlDocumentFromFile(fileName, errMsg, errLine, errColumn);
DebugN("Dokument-ID:", Id);
DebugN("Möglicher Fehler:", errMsg, errLine, errColumn);
node = xmlFirstChild(1);
DebugN(node);
i = xmlNodePosition(1,node,line,col);
DebugN("Pos: "+line,col);
Assignment
Availability
CTRL. In every script where the "CtrlXml" extension (#uses "CtrlXml") is used.