【发布时间】:2014-02-02 16:58:58
【问题描述】:
我有一个这样的 xml 文件
<pr_id>01</pr_id>
<uniprot>O11482</uniprot>
<uniprot>O96642</uniprot>
<uniprot>Q67845</uniprot>
<column>
<column_id>1</column_id>
column_start>300</column_start>
<column_end>334</column_end>
<old_new>old</old_new>
<comment></comment>
</column>
<column>
<column_id>2</column_id>
<column_start>335</column_start>
<column_end>337</column_end>
<old_new>new</old_new>
<comment></comment>
<pr_id>02</pr_id>
<uniprot>P4455</uniprot>
<uniprot>89WER8</uniprot>
<uniprot>Q12845</uniprot>
<column>
<column_id>1</column_id>
<column_start>12</column_start>
<column_end>34</column_end>
<old_new>old</old_new>
<comment></comment>
</column>
<column>
<column_id>2</column_id>
<column_start>35</column_start>
<column_end>37</column_end>
<old_new>old</old_new>
<comment></comment>
我想得到如下输出。
pr_id uniprot old_start old_end
01 O11482 300 334
02 P4455 12 34
02 P4455 35 37
实现这一目标的简单方法是什么?这是我第一次处理xml文件。您的宝贵建议将不胜感激!
【问题讨论】:
-
确保 XML 格式正确,然后使用任何 XML 解析器。
-
为什么不希望输出列号。 2 代表
pr_id=01?