さて、私はxmlを配列に戻す際に問題を抱えていました....各xmlが同じ形式に従っている場合は簡単ですが、<Formula>
タグ、formulaname、およびmovespeed exを除いてすべてのXMLは異なります。
<Formula>
<formulaname>Basic</formulaname>
<movespeed>1</movespeed>
<str>4</str>
<dex>3</dex>
<int>1</int>
<will>2</will>
</Formula>
また
<Formula>
<formulaname>Basic</formulaname>
<movespeed>1</movespeed>
<box>4</box>
<chicken>3</chicken>
<ducks>1</ducks>
<cereal>2</cereal>
</Formula>
私が試したこと:
$xml = simplexml_load_file("test.xml");
print_r($xml);
これは実際にはprints
何かですが、私はそれを乗り越えることができませんでしecho
た..
foreach($xml->text as $string) {
print_r($string);
echo 'attributes: '. $string->attributes() .'<br />';
}
機能しませんでした。もともとは目的でしstrings
たが、どれもstrings
...
foreach ($xml->Formula as $element) {
foreach($element as $key => $val) {
echo "{$key}: {$val}";
}
どちらも機能しませんでしたarray
。値が正確に何と呼ばれるかを知らなくても値を使用できるように、このようなものが必要でした..