Hello what is the wrong with this code?
i want but the $data in variables from xml file and use it out of function??
i use this way to take the information from XML file and fill it in Form?is this good way ,, thx 4 everyone
this is the php code
<?
function startElement($xml_parser, $name, $attributes) {
global $current;
$current=$name;
print("<p>Encountered Start Element For: $name\n");
}
function endElement($xml_parser, $name) {
print("<p>Encountered End Element For: $name\n");
}
function characterData($xml_parser, $data) {
global $current;
global $BB;
global $AA;
if($data != "\n") {
print("<p>Encountered Character Data: $data\n");
}
if ($current == "TITLE22"){
$AA=$data;
echo "<br><br>".$AA;
}
if ($current == "BODY"){
$BB=$data;
echo "<br><br>".$BB;
}
}
function load_data($file) {
$fh = fopen($file, "r") or die ("<P>COULD NOT OPEN FILE!");
$data = fread($fh, filesize($file));
return $data;
}
/***** MAIN *****/
$file = "simple2.xml";
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
xml_parse($xml_parser, load_data($file)) or die ("<P>ERROR PARSING XML!");
xml_parser_free($xml_parser);
echo "<br><br>***";
echo $AA;
echo "<br><br>***";
echo $BB;
echo "<br><br>***";
?>
<?xml version="1.0"?>
<document>
<title22>XML Exposed000000</title22>
<body>Demystifying XML. Read about it here.</body>
</document>