我有一个巨大的文本文件,我想编写一个程序,它只能从文件中提取 XML 并保存它。
是否有直接的 API 或比拆分/修剪从文件中读取的字符串更好的解决方案。
示例:文件的一小部分:
#---------- #1 : ----------#
<MSG_INFO>
<message type="TextMessage" messageSelector="" originationTimestamp="" receiveTime="" jmsServerTimestamp="" jmsMsgExpiration="">
<header JMSDestinationType="Generic" JMSDeliveryMode="2" />
<properties>
<property name="messageTopic" type="String">xyz</property>
</properties>
</message>
BodyLength=1476
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>