How can I get info from an XML document
| From: | user at domain dot invalid | Date: | Sat, 22 Mar 2003 01:13:43 +0000 |
| Subject: | How can I get info from an XML document | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-140645@lists.php.net to get a copy of this message | ||
Hi,
I can't get the clue. My php page receives an XML document from which I
need to get the contents and attributes into php variables. I obvious have missed something important. Could someone help me with the following script (while watching the Bagdad bombings on CNN):
<?
$xml="<?xml version='1.0' ?>"; //if fact, I get the $xml from elsewhere
$xml.="<xmlContainer>";
$xml.="<name>Mike Bosschaert</naam>";
$xml.="</xmlContainer>";
$xmlParser=xml_parser_create();
$parse_succes = xml_parse($xmlParser,$xml,"true");
xml_set_element_handler($xmlParser, "startElement", "endElement");
xml_set_character_data_handler($xmlParser, "characterData");
xml_parse($xmlParser, $datastring, true);
xml_parser_free($xmlParser);
?>
I want to create a variable $name, pointing to "Mike Bosschaert"
Thanks,
Mike