0
0

[PHP] xmlを読み込み、連想配列に格納する

Posted at

PHPでxmlを読み込み、連想配列に格納する

  • chatGPTだと回答が不安定なので自分用にメモ。
    $xml = simplexml_load_string(file_get_contents('https://target.xml'), 'simpleXMLElement', LIBXML_NOCDATA | LIBXML_BIGLINES);
    if ($xml === FALSE) {
        die("Failed to parse XML data.");
    }
    $ary = json_decode(json_encode($xml));
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0