私はPHPの単純なXML関数を使用してXMLファイルを操作してきました。
以下のコードは、単純なXML階層に対して正常に機能します。
$xml = simplexml_load_file("test.xml");
echo $xml->getName() . "<br />";
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child . "<br />";
}
これは、XMLドキュメントの構造が次のとおりであることを前提としています。
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
ただし、XMLドキュメント内にもっと複雑な構造がある場合、コンテンツは単に出力されません。より複雑なXMLの例を以下に示します。
<note>
<noteproperties>
<notetype>
TEST
</notetype>
</noteproperties>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
深さが不定のXMLファイルを処理する必要があります-誰かが方法を提案できますか?