重新排列xml元素并重命名标记

时间:2015-05-30 17:24:29

标签: xml

我有一个xml,其中包含所有数据。 但它的顺序错误,标签错误。

如何将输入文件转换为下面的输出文件?

输入:

<?xml version="1.0" encoding="utf-8"?>
<orders>
  <order>
    <id>7140930</id>
    <status>processing_awaiting_shipment</status>
    <addressShippingCompany>false</addressShippingCompany>
    <addressShippingName>name</addressShippingName>
    <addressShippingStreet>street</addressShippingStreet>
    <addressShippingStreet2/>
    <addressShippingNumber>2</addressShippingNumber>
    <addressShippingExtension/>
    <addressShippingZipcode>1111</addressShippingZipcode>
    <addressShippingCity>city</addressShippingCity>
    <addressShippingRegion/>
    <addressShippingCountry>
      <id>21</id>
      <code>be</code>
      <code3>bel</code3>
      <title>Belgium</title>
    </addressShippingCountry>
  </order>
</orders>

输出:

<?xml version="1.0" encoding="utf-8"?>
<NAVIPWMS>
  <IDENTIFICATION>
    <PROCESSTYPE>OUTBOUNDORDER</PROCESSTYPE>
  </IDENTIFICATION>
  <HEADER>
    <DATE>20150126</DATE>
    <CUSTNOEXT>K00020</CUSTNOEXT>
    <ORDTYPE>UIT</ORDTYPE>
    <PERSONALMSG>
      <LINE></LINE>
    </PERSONALMSG>
    <SENDERCOMMENT></SENDERCOMMENT>
    <ADDRESSES>
      <ADDRESS>
        <ADDRTYPE>UNLOADING</ADDRTYPE>
        <ADDRCODE></ADDRCODE>
        <ADDRNAME>name</ADDRNAME>
        <ADDRESS1>street + number</ADDRESS1>
        <ADDRESS2></ADDRESS2>
        <HOUSENO></HOUSENO>
        <CNTRY>DEU</CNTRY>
        <CITY>Essen</CITY>
        <POSTC>45329</POSTC>
        <REF>21635</REF>
        <CONTACT>contactinfo</CONTACT>
        <PHONE>0000</PHONE>
        <EMAIL></EMAIL>
      </ADDRESS>
    </ADDRESSES>
  </HEADER>
</NAVIPWMS>

我希望在正确的输出标记(<addressShippingName>)中填写<ADDRNAME> 并合并<addressShippingStreet><addressShippingNumber>并将其填入<ADDRESS1>

0 个答案:

没有答案