0

次のようなコードがあります。

if (file_exists('my.xml')) {
    $xml = simplexml_load_file('my.xml');
    if($xml === NULL)
        echo('ERR NULL $xml</br>');
    else{
        echo('> my.xml opened</br>');   
        print_r($xml);
    }
}

foreach($xml->data->record as $records){
    echo $records->data_to_retrive, PHP_EOL;
}
echo('> Ended</br');

これで、出力は次のようになります。

> my.xml opened
> Ended

それで、それの何が問題なのですか?なぜt show data_to_retrive, and print_r($xml) don機能しないのですか?私はここで立ち往生し、ほとんど頭痛がしました。

4

2 に答える 2

0
$file = fopen('my.xml','r');
$prexml = fread($file, filesize('my.xml'));
$prexml = preg_replace('#<([0-9]+)>#si','<z$1>',$prexml);
$prexml = preg_replace('#</([0-9]+)>#si','</z$1>',$prexml);
echo('> File opened</br>');
$xml = new SimpleXMLElement($prexml);

さて、私はそのように my.xml を修復し、現在は機能しています。アイデアをありがとうヤング!

于 2013-09-23T12:28:37.783 に答える