从 XML 文件中删除标头的简单方法
我需要从另一个程序生成的文件中删除非 xml 标签。
该文件是这样的:
Executing Command - Blah.exe ...
-----Command Output-----
HTTP/1.1 200 OK
Connection: close
Content-Type: text/xml
<?xml version="1.0"?>
<testResults>
<finalCounts>
<right>7</right>
<wrong>4</wrong>
<ignores>0</ignores>
<exceptions>0</exceptions>
</finalCounts>
</testResults>
Exit-Code: 15
How to remove the non-xml text easy in java?
I need remove non-xml tags from file generated by another program.
The file is some like this:
Executing Command - Blah.exe ...
-----Command Output-----
HTTP/1.1 200 OK
Connection: close
Content-Type: text/xml
<?xml version="1.0"?>
<testResults>
<finalCounts>
<right>7</right>
<wrong>4</wrong>
<ignores>0</ignores>
<exceptions>0</exceptions>
</finalCounts>
</testResults>
Exit-Code: 15
How to remove the non-xml text easily in java?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来像直接 HTTP 输出...所以只需扫描前两个连续换行符(可能在它们前面有回车符)就会得到要过滤掉的前缀的末尾。
This looks like direct HTTP output... so just scanning for the first two consecutive line feeds (probably with carriage returns in front of them) will give you the end of the prefix you want to filter out.