我想讀取整個文本文件,並獲取&保存整個第二XML在我的本地驅動器基於搜索輸入如何在包含許多xml文件的文本文件中識別xml以及使用Java中xml節點的其他文本?
三更雨
文本文件的內容:
<?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>
</catalog>
controllercmds.statusupdate
ExtnClientExternalSrcProcess="9"
<catalog>
<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>
</catalog>'
我的輸出應該是:
<catalog>
<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>
</catalog>
這是可行的嗎?有人可以幫助我
問題尚不清楚..在編程你正在閱讀的XML內容> – Vishal
請粘貼Java代碼以及與您已經嘗試.. – Vishal
我試着用緩衝閱讀器的BufferedReader BR =新的BufferedReader(新的InputStreamReader( \t \t \t \t \t \t \t sftp.get(file.getFilename()))); \t \t \t \t \t嘗試{ \t \t \t \t \t \t \t而((行= br.readLine())!= NULL){ \t \t \t \t \t \t \t \t如果(line.contains(「<? xml version「){ \t \t \t \t \t \t \t \t \t sb。追加(線); \t \t \t \t \t \t \t \t} \t \t \t \t \t \t \t} \t \t \t \t \t \t的System.out.println(SB);但是識別和附加數據花費的時間太長。 –