Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With libxml, how to get the character position of a given element or attribute in the source xml file?

With libxml2, we can use xmlGetLineNo to get the line number in which a node appears in the source XML file.

But how to get character positions of a given element and a given attribute? I need both the start and end positions in the source xml file for both a node and an attribute.

Thanks!

like image 713
Edwin Yip Avatar asked Nov 05 '22 12:11

Edwin Yip


1 Answers

You can use the SAX2 interface which has the xmlSAX2GetColumnNumber method.

like image 85
Cito Avatar answered Nov 10 '22 20:11

Cito