Open zishiguo opened 5 years ago
$data = [
'urlset' => [
'@attributes' => [
'content_method' => 'full'
],
[
'@name' => 'url',
'loc' => 'http://www.example.com/a.html',
'desc' => 'a.html'
], [
'@name' => 'url',
'loc' => 'http://www.example.com/b.html',
'desc' => 'b.html'
]
]
];
$request_xml = Formatter::make($data, Formatter::ARR)->toXml('xml','utf-8',true);
dd($request_xml);
结果
<?xml version="1.0" encoding="utf-8"?>
<xml>
<urlset content_method="full">
<url>
<loc>http://www.example.com/a.html</loc>
<desc>a.html</desc>
</url>
<url>
<loc>http://www.example.com/b.html</loc>
<desc>b.html</desc>
</url>
</urlset>
</xml>
If xml likes:
Then, the array is ?