如何从 xml 节点中准确删除不需要的父节点并保持数据完整?像数组移位之类的东西。例如,我有一个数组
[LineItems] => Array
(
[0] => Array
(
[LineItem] => Array
(
[Description] => iPhone
[Quantity] => 1
[UnitAmount] => 101.0000
[AccountCode] => 200
[TaxAmount] => 0.0000
[LineAmount] => 101.0000
)
)
[1] => Array
(
[LineItem] => Array
(
[Description] => Flat Shipping Rate
[Quantity] => 1
[AccountCode] => 200
[UnitAmount] => 5.0000
[LineAmount] => 5.0000
)
)
)
如何准确删除 LineItems[0] 和 LineItems[1] 并将 LineItem 数组推到左侧?我正在寻找这样的东西:
[LineItems] => Array
(
[LineItem] => Array
(
[Description] => iPhone
[Quantity] => 1
[UnitAmount] => 101.0000
[AccountCode] => 200
[TaxAmount] => 0.0000
[LineAmount] => 101.0000
)
)
[LineItem] => Array
(
[Description] => Flat Shipping Rate
[Quantity] => 1
[AccountCode] => 200
[UnitAmount] => 5.0000
[LineAmount] => 5.0000
)
)
此外,当转换数组时:
Array
(
[Invoices] => Array
(
......something....
)
)
转换成xml时,xml会输出
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Invoices>
</Invoices>
</root>
我如何实际删除根?
提前致谢。