0
取消xml節點取決於多個數組?刪除xml節點取決於多個數組?
我的原始XML文件這樣的(original.xml)
<books>
<book>
<qty>12</qty>
<title>C++</title>
</book>
<book>
<qty>21</qty>
<title>PHP</title>
</book>
</books>
<books>
<book>
<qty>25</qty>
<title>Java</title>
</book>
<book>
<qty>32</qty>
<title>Python</title>
</book>
<book>
<qty>22</qty>
<title>History</title>
</book>
</books>
我有一個數組使用操縱到新的XML文件(new.xml)
$arr = Array (
[0] => Array (
[0] => 12;C++
[1] => 21;PHP
)
[1] => Array (
[0] => 25;java
[1] => 32;Python
)
)
依靠上述陣列==> new.xml將如下所示:
//tag `<book>` block has removed because it contain all elements in an array ($arr)
<books>
<book>
<qty>22</qty>
<title>History</title>
</book>
</books>
所有book元素應該有相同的標籤``,不``,``等等 –
2010-12-22 08:22:18
@Tatu準確。 ` `是正確的做法。如果每本書都需要編號,它應該是一個屬性:' ` –
2010-12-22 08:25:14