PHPでxmlデータを取得する際に問題が発生しています
私の xml はかなり複雑で、タグにはネストされた子がいくつかあります。
xml
?xml version="1.0" encoding="UTF-8"?>
<book id="5">
<title id="76">test title</title>
<figure id="77"></figure>
<ch id="id78">
<aa id="80"><emph>content1</emph></aa>
<ob id="id_84" page-num="697" extra-info="4"><emph type="bold">opportunity.</emph></ob>
<ob id="id_85" page-num="697" extra-info="5"><emph type="bold">test data.</emph></ob>
<para id="id_86" page-num="697">2008.</para>
<body>
..more elements
<content>more contents..
</content>
</body>
</ch>
マイコード
//I need to load many different xml files.
$xml_file = simplexml_load_file($filename);
foreach ($xml_file->children() as $child){
echo $child->getName().':'. $child."<br>";
}
上記のコードは表示のみです
book, title, figure, ch
ch
タグ内の要素ではありません。各タグ内のすべての要素を表示するにはどうすればよいですか? 任意のヒント?どうもありがとう!