我想解析本质上是日志文件的xml文件。它们根本没有结构,只是逐行输出。 像这样:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="_LoggingStyle.xsl"?>
<Logs>
<Entry Type="Info" Time="12:08:45.747440" Text="Starting TCP Server."/>
<Entry Type="Debug" Time="12:08:53.126240" " Text="Test:= Preparing to send image #1"/>
<Entry Type="Result" Time="12:09:03.047840" " Text="Result from TCP is correct!"/>
<Entry Type="Debug" Time="12:10:34.292240" " Text="Get State"/>
</Logs>
最后,我想要一个像这样的数组:
Info 12:08:45.747440 Starting TCP Server.
Debug 12:08:53.126240 Test:= Preparing to send image #1
Result 12:09:03.047840 Result from TCP is correct!
Debug 12:10:34.292240 Get State
我查看了SimpleXML,但对我而言似乎没有帮助。我还查询了是否可以手动逐行解析XML,但是我什至找不到办法。