Using PHP's XMLReader, how do I get the line number of the current node?

泪湿孤枕 提交于 2019-12-10 18:32:01

问题


Using the XMLReader XML parser in PHP 5.3, I need to get the line number of the current node. A column number or total offset from the beginning of the file would be nice, too.

Hopefully I don't have to use some hack like parsing every raw node string for newlines (with readOuterXML()), but I don't see a getLineNo() property like in the DOM...


回答1:


See XMLReader::expand which returns a DOMNode element, which in turn supports getLineNo()



来源:https://stackoverflow.com/questions/2530679/using-phps-xmlreader-how-do-i-get-the-line-number-of-the-current-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!