Php/xml/SimpleXMLElement
提供: 初心者エンジニアの簡易メモ
配列からxml生成
$xmlstr = "<?xml version='1.0' encoding='utf-8'?><tags></tags>"; $xml = new SimpleXMLElement($xmlstr); $tags = [ 'name' => 'taro', 'age' => 1 ]; foreach($tags as $key => $value) { $xml->addChild($key, $value); } echo $xml->asXML();
xmlから配列へ
$xml = simplexml_load_string($resxml); $json = json_encode($xml); $array = json_decode($json, TRUE); print_r($array);
utf-8をエスケープしないように
echo json_encode($kanaMappings, JSON_UNESCAPED_UNICODE);