xml形式の文字列からxmlオブジェクトを生成する
- PHP
-
2009-10-02 - 更新:2014-06-05
この記事は最終更新日から1年以上経過しています。
$xmlstr = file_get_contents("[XMLファイル名]");
if(!$dom = domxml_open_mem($xmlstr))
{
echo "Error while parsing the document\n";
exit;
}
$root = $dom->document_element(); $childnodes = $root->child_nodes();
foreach ($childnodes as $value)
{
$nodeArray[$value->tagname] = $value->get_content();
$chnode = $value->child_nodes();
foreach($chnode as $v)
{
echo $v->tagname . " : " . $v->get_content() . "<br />";
}
echo "<br />";
}
この記事がお役に立ちましたらシェアお願いします
1,404 views




