擅长:python、mysql、java
<blockquote>
<p><strong>Question</strong>: ... any idea, how should i parse this?</p>
</blockquote>
<p>过滤整个文件并拆分为有效的<code><?xml ...</code>块。<br/>
创建<code>myfile_01, myfile_02 ... myfile_nn</code>。在</p>
<pre><code>n = 0
out_fh = None
with open('myfile.xml') as in_fh:
while True:
line = in_fh.readline()
if not line: break
if line.startswith('<?xml'):
if out_fh:
out_fh.close()
n += 1
out_fh = open('myfile_{:02}'.format(n))
out_fh.write(line)
out_fh.close()
</code></pre>
<p>如果您希望所有<code><country></code>在一个<code>XML Tree</code>中:</p>
^{pr2}$
<p><strong><em>用Python:3.4.2</em>测试</p>