1

PHPでxmlドキュメントを作成しようとしています。

しかし、それをしようとすると、次のエラーが発生します。

This page contains the following errors:

error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.

私の情報源:

<?php

header('Content-Type: text/xml');

print(htmlentities('<?xml version="1.0" encoding="UTF-8"?>
<bbcodes>
<block>
<pattern><![CDATA[<p.*?>]]></pattern>
<replace><![CDATA[[p]]]></replace>
</block>
<block>
<pattern><![CDATA[</p>]]></pattern>
<replace><![CDATA[[/p]]]></replace>
</block>
</bbcodes>'));

?>

何か案は?

4

1 に答える 1

4

あなたのコードで同じエラーが発生します。htmlentities 関数を削除すると、問題なく動作します。

<?php

header('Content-Type: text/xml');

print('<?xml version="1.0" encoding="UTF-8"?>
<bbcodes>
<block>
<pattern><![CDATA[<p.*?>]]></pattern>
<replace><![CDATA[[p]]]></replace>
</block>
<block>
<pattern><![CDATA[</p>]]></pattern>
<replace><![CDATA[[/p]]]></replace>
</block>
</bbcodes>');

?>
于 2013-01-05T23:40:55.297 に答える