【发布时间】:2015-05-22 12:28:12
【问题描述】:
我有一个由 MS Excel 创建的 XML 文档。我想要的是组合具有相同 id 的节点。我目前拥有的xml是这样的:
<ns1:publications>
<ns1:book id="3" subType="book">
<ns1:peerReviewed>false</ns1:peerReviewed>
<ns1:publicationCategory>scientific</ns1:publicationCategory>
<ns1:publicationStatus>published</ns1:publicationStatus>
<ns1:language>en_GB</ns1:language>
<ns1:title>
<ns2:text lang="en" country="EN">Kirja3</ns2:text>
</ns1:title>
<ns1:abstract>
<ns2:text lang="en" country="EN">
</ns1:abstract>
<ns1:persons>
<ns1:author>
<ns1:role>author</ns1:role>
<ns1:person external="false" id="3">
<ns1:firstName>Rob</ns1:firstName>
<ns1:lastName>Hubbard</ns1:lastName>
</ns1:person>
</ns1:author>
</ns1:persons>
<ns1:organisations>
<ns1:organisation id="220400"/>
</ns1:organisations>
<ns1:owner id="220400"/>
<ns1:publicationDate>
<ns2:year>2014</ns2:year>
</ns1:publicationDate>
<ns1:visibility>Public</ns1:visibility>
<ns1:numberOfPages>655</ns1:numberOfPages>
<ns1:placeOfPublication>Newcastle</ns1:placeOfPublication>
</ns1:book>
<ns1:book id="3">
<ns1:title/>
<ns1:abstract/>
<ns1:persons>
<ns1:author>
<ns1:person id="4">
<ns1:firstName>Chris</ns1:firstName>
<ns1:lastName>Steward</ns1:lastName>
</ns1:person>
</ns1:author>
</ns1:persons>
<ns1:organisations>
<ns1:organisation id="220400"/>
</ns1:organisations>
<ns1:owner id="220400"/>
<ns1:publicationDate/>
</ns1:book>
它应该是这样的:
<ns1:publications>
<ns1:book id="3" subType="book">
<ns1:peerReviewed>false</ns1:peerReviewed>
<ns1:publicationCategory>scientific</ns1:publicationCategory>
<ns1:publicationStatus>published</ns1:publicationStatus>
<ns1:language>en_GB</ns1:language>
<ns1:title>
<ns2:text lang="en" country="EN">Kirja3</ns2:text>
</ns1:title>
<ns1:abstract>
<ns2:text lang="en" country="EN">
</ns1:abstract>
<ns1:persons>
<ns1:author>
<ns1:role>author</ns1:role>
<ns1:person external="false" id="3">
<ns1:firstName>Rob</ns1:firstName>
<ns1:lastName>Hubbard</ns1:lastName>
</ns1:person>
</ns1:author>
<ns1:author>
<ns1:person external="false" id="4">
<ns1:firstName>Chris</ns1:firstName>
<ns1:lastName>Steward</ns1:lastName>
</ns1:person>
</ns1:author>
</ns1:persons>
<ns1:organisations>
<ns1:organisation id="220400"/>
<ns1:organisation id="220300"/>
</ns1:organisations>
<ns1:owner id="220400"/>
<ns1:publicationDate>
<ns2:year>2014</ns2:year>
</ns1:publicationDate>
<ns1:visibility>Public</ns1:visibility>
<ns1:numberOfPages>655</ns1:numberOfPages>
<ns1:placeOfPublication>Newcastle</ns1:placeOfPublication>
</ns1:book>
数据来自包含行信息的 Excel 电子表格。例如,书可以有多个作者,并且它们位于不同的行中,第一列具有相同的 id。
【问题讨论】: