以下に、私の xml ドキュメントがあります。
<?xml version="1.0" encoding="ISO-8859-1"?>
<app>
<version>0925</version>
<humanVersion>0.9.25</humanVersion>
</app>
これが私のphpです:
$completeurl = "ota/shingle/shingle.xml";
$xml = simplexml_load_file($completeurl);
$updateVer = $xml->version;
$updateVerHuman = $xml->humanVersion;
私はphp変数を取得してjson文字列に入れています。ここに出力があります:
{"updateVer":{"0":"0925"},"updateVerHuman":{"0":"0.9.25"}}
updateVer と updateVerHuman のデータが {} で囲まれ、"0" が含まれているのはなぜですか?? その値のデータのみが必要です。どうすればこれを達成できますか?
私はこれを試しましたが、同じ結果が得られます:
$updateVer = $xml->version[0];
$updateVerHuman = $xml->humanVersion[0];