我想从这些数组创建一个XML文档。数组看起来像这样:
Array
(
[0] => Firstname1
[1] => Firstname2
[2] => Firstname3
)
Array
(
[0] => Lastname1
[1] => Lastname2
[2] => Lastname3
)
...........
我希望XML文档的结构如下:
<Member>
<Firstname>Firstname1</Firstname>
<Lastname>Lastname1 </Lastname>
</Member>
我该怎么做?谢谢你的帮助!
答案 0 :(得分:3)
使用此:http://php.net/manual/en/book.simplexml.php
和代码(例如,如何构建这样的结构):
$xml = new SimpleXMLElement('<xml></xml>');
foreach($first as $k=>$v){
$member = $xml->addChild('Member');
$member->addChild('Firstname',$v);
$member->addChild('Lastname',$last[$k]);
}