我有以下 XML 文件,其中每个 SALES 标记中都有重复的 DateSold 标记。我需要将它们替换为 DateSold 和 TimeSold。或者将日期和时间部分合并为一个标签。
源 XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<SALES>
<InvoiceID>A13A30000011</InvoiceID>
<LineID>1</LineID>
<UPC>058030020130</UPC>
<Desc>PS WQ VIT E 200IU 100'S</Desc>
<DateSold>2013-10-30</DateSold>
<DateSold>10:02:42</DateSold>
<QTY>000001</QTY>
<UnitRetail>000006.99</UnitRetail>
<UnitCost>000003.37</UnitCost>
</SALES>
<SALES>
<InvoiceID>A13A30000021</InvoiceID>
<LineID>2</LineID>
<UPC>063601699165</UPC>
<Desc>GENTEAL GEL DROPS 15ML</Desc>
<DateSold>2013-10-30</DateSold>
<DateSold>10:03:15</DateSold>
<QTY>000001</QTY>
<UnitRetail>000010.99</UnitRetail>
<UnitCost>000007.44</UnitCost>
</SALES>
</root>
输出将是:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<SALES>
<InvoiceID>A13A30000011</InvoiceID>
<LineID>1</LineID>
<UPC>058030020130</UPC>
<Desc>PS WQ VIT E 200IU 100'S</Desc>
<DateSold>2013-10-30</DateSold>
<TimeSold>10:02:42</TimeSold>
<QTY>000001</QTY>
<UnitRetail>000006.99</UnitRetail>
<UnitCost>000003.37</UnitCost>
</SALES>
<SALES>
<InvoiceID>A13A30000021</InvoiceID>
<LineID>2</LineID>
<UPC>063601699165</UPC>
<Desc>GENTEAL GEL DROPS 15ML</Desc>
<DateSold>2013-10-30</DateSold>
<TimeSold>10:03:15</TimeSold>
<QTY>000001</QTY>
<UnitRetail>000010.99</UnitRetail>
<UnitCost>000007.44</UnitCost>
</SALES>
</root>
可以合并为
<SALES>
<InvoiceID>A13A30000021</InvoiceID>
<LineID>2</LineID>
<UPC>063601699165</UPC>
<Desc>GENTEAL GEL DROPS 15ML</Desc>
<DateSold>2013-10-30 10:03:15</TimeSold>
<QTY>000001</QTY>
<UnitRetail>000010.99</UnitRetail>
<UnitCost>000007.44</UnitCost>
</SALES>