SimpleXMLElement を使用して URL から XML ファイルを解析しようとしています。私が試すとき:
$url = 'http://dl.dropbox.com/u/27440550/test.xml';
$xml = new SimpleXMLElement($url, 0, true, "", false);
すべて正常に動作し、XML ドキュメントにアクセスして解析できます。URL は、xml ファイルを保存したドロップボックス パブリック フォルダーへのリンクであることに注意してください。
URLから直接ファイルを取得しようとすると:
$url = 'https://multidoc.eia-fr.ch/record/1220/export/xd';
$xml = new SimpleXMLElement($url, 0, true, "", false);
奇妙なエラーが発生します:
Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: Entity: line 1: parser error : Start tag expected, '<' not found in C:\wamp\www\metamin\getxml.php on line 5
Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: https://multidoc.eia-fr.ch/record/1220/export/xd in C:\wamp\www\metamin\getxml.php on line 5
Warning: SimpleXMLElement::__construct() [<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]: ^ in C:\wamp\www\metamin\getxml.php on line 5
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\wamp\www\metamin\getxml.php on line 5
Exception: String could not be parsed as XML in C:\wamp\www\metamin\getxml.php on line 5
XMLファイルとして認識されていないと思いますが、なぜですか?私は同じことをしていませんか?