0
我是一個操作xml的新手,希望我能從你們那裏得到一些幫助。刪除XML中的節點
我的後端系統用下面的節點結構吐出一個XML文件。
<orders xmlns="http://www.foo.com/xml/impex/order/">
<order order-no="0000000000000303">
<order-date>2011-09-02T18:55:00.000Z</order-date>
<created-by>foo</created-by>
<original-order-no>0000000000000303</original-order-no>
<currency>USD</currency>
<customer-locale>default</customer-locale>
<affiliate-partner-name/>
<affiliate-partner-id/>
<invoice-no>00001422</invoice-no>
<customer>...</customer>
<customer-order-reference/>
<status>...</status>
<replace-code/>
<replace-description/>
<replacement-order-no/>
<replaced-order-no/>
<current-order-no>0000000000000303</current-order-no>
<cancel-code/>
<cancel-description/>
<product-lineitems>...</product-lineitems>
<giftcertificate-lineitems/>
<shipping-lineitems>...</shipping-lineitems>
<shipments>...</shipments>
<totals>...</totals>
<payments>
<payment>
<gift-certificate>
<custom-attributes>
<custom-attribute attribute-id="giftCard01Number">01000169466975</custom-attribute>
<custom-attribute attribute-id="giftCard01Value">10.00</custom-attribute>
<custom-attribute attribute-id="giftCard02Number">01100995910</custom-attribute>
<custom-attribute attribute-id="giftCard02Value">20.00</custom-attribute>
<custom-attribute attribute-id="giftCertificateType">card</custom-attribute>
</custom-attributes>
</gift-certificate>
<amount>10.00</amount>
<processor-id>BARNEYS_GIFT_CARD</processor-id>
<transaction-id>0000000000000303</transaction-id>
</payment>
<payment>
<gift-certificate>
<custom-attributes>
<custom-attribute attribute-id="giftCard02Number">01100995910</custom-attribute>
<custom-attribute attribute-id="giftCard02Value">20.00</custom-attribute>
<custom-attribute attribute-id="giftCertificateType">card</custom-attribute>
</custom-attributes>
</gift-certificate>
<processor-id>BARNEYS_GIFT_CARD</processor-id>
</payment>
<payment>
<credit-card>...</credit-card>
<amount>35.33</amount>
<processor-id>VCOMMERCE_CREDIT</processor-id>
<transaction-id>0000000000000303</transaction-id>
<custom-attributes>...</custom-attributes>
</payment>
</payments>
<remoteHost/>
<external-order-no/>
<external-order-status/>
<external-order-text/>
<custom-attributes>...</custom-attributes>
</order>
</orders>
現在需要更改的部分是訂單節點。 需要保留的數據是第一個和最後一個付款節點。 任何其他的節點落在中間可以被刪除或刪除。 E4x有沒有辦法做到這一點?
感謝您的幫助。 葉貝
什麼是 「reming」?你的意思是重命名?刪除? – Oded
爲什麼你需要使用E4X?您提到XML文件是在後端生成的,那麼您是否無法使用後端語言/技術來操作XML文件? – clarkb86
如果有2個付款節點會怎麼樣?你首先和最後刪除?爲了避免這兩個問題,你可以刪除它們嗎? –