Hi all
I am novice in XML. I have just started to creating PHP parser for XML files. I am using SAX.
the file is : -
-
<html>
-
<head>
-
<basefont face="Arial">
-
</head>
-
<body>
-
<?php
-
// cdata handler
-
function characterDataHandler($parser, $data)
-
{
-
echo $data . "<p>";
-
}
-
-
// PI handler
-
function PIHandler($parser, $target, $data)
-
{
-
// if php code, execute it
-
if (strtolower($target) == "php")
-
{
-
eval($data);
-
}
-
// otherwise just print it
-
else
-
{
-
echo "PI found: [$target] $data";
-
}
-
}
-
-
// XML data
-
$xml_data = <<<EOF
-
<?xml version="1.0"?>
-
<article>
-
<header>insert slug here</header>
-
<body>insert body here</body>
-
<footer><?php print "Copyright UNoHoo Inc," . date("Y", mktime()); ?></footer>
-
</article>
-
EOF;
-
-
// initialize parser
-
$xml_parser = xml_parser_create();
-
// set cdata handler
-
xml_set_character_data_handler($xml_parser, "characterDataHandler");
-
// set PI handler
-
xml_set_processing_instruction_handler($xml_parser, "PIHandler");
-
if (!xml_parse($xml_parser, $xml_data))
-
{
-
die("XML parser error: " .
-
xml_error_string(xml_get_error_code($xml_parser)));
-
}
-
-
// all done, clean up!
-
xml_parser_free($xml_parser);
-
?>
-
</body>
-
</html>
Next time read the Posting Guidelines at the top of this forum before you post anything! Especially the part about enclosing shown code within code, php or html tags! - Ronald
it give this output " XML parser error: Reserved XML Name"
I am unable to understand why its come.
Please help me out.
onewaylife