使用PHP的XMLReader,如何获取当前节点的行号?

时间:2021-07-05 07:29:27

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.

使用PHP 5.3中的XMLReader XML解析器,我需要获取当前节点的行号。从文件开头的列号或总偏移量也很不错。

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...

希望我不必使用一些hack,比如解析换行的每个原始节点字符串(使用readOuterXML()),但我没有看到像DOM中的getLineNo()属性...

1 个解决方案

#1


1  

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

请参阅XMLReader :: expand,它返回一个DOMNode元素,该元素又支持getLineNo()

#1


1  

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

请参阅XMLReader :: expand,它返回一个DOMNode元素,该元素又支持getLineNo()