开发者

PHP xmlparser with $_GET parameter

I use a xml_parser to parse an xml. When I have a string like

$simple = "<para><note>simple note</note></para>";

it works. But the problem is when I use a $_GET parameter.

$simple = "<para><note>simple note</note></para>";
$parser = xml_parser_create();
$valid = xml_parse_into_struct($parser, $simple, $response, $index);
xml_parser_free($parser);
echo $valid;

When run xml.php, it returns 1. It works

$simple= $_GET['simple'];
$parser = xml_parser_create();
$valid = xml_parse_into_struct($parser, $simple, $response, $index);
xml_parser_free($parser);
echo $valid;

When run

xml.php?simple=<para&开发者_Python百科gt;<note>simple note</note></para>

It returns 0. It doesn´t work.

But the $_GET parameter is OK:

echo $_GET['simple] 

prints

<para><note>simple note</note></para>

By the way, I have magic quotes off.

Thank you very much


Since what you see on the screen/browser is <para><note>simple note</note></para> It probably means the < and > are not really tag delimiters. (but &gt; and &lt;) Do view source on the page when you do the echo, and the truth will come out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜