Read XML file
| From: | Christian Ista | Date: | Wed, 16 Oct 2002 09:47:33 +0000 |
| Subject: | Read XML file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-120136@lists.php.net to get a copy of this message | ||
Hello,
Look the code below. The code work I can see on the screen the value of
each tags (except SOFT, no need it). I'd like now put the value in a 2
dimensions array, for each tag, first cell the tag name, and the value in
the second cell. Could you tell me the change to do ?
Thanks,
Christian,
<?php
$parser = xml_parser_create();
xml_set_element_handler($parser, "startElement", "endElement");
xml_set_character_data_handler($parser, "characterData");
$filehandler = fopen("FileXML.xml", "r");
while ($data = fread($filehandler, 4096)) {
xml_parse($parser, $data, feof($filehandler));
}
fclose($filehandler);
xml_parser_free($parser);
function startElement($parser, $tag) {
switch($tag){
case "SOFT":
break;
default :
break;
}
}
function endElement($parser, $tag) {
}
string function characterData($parser_instance, $xml_data) {
echo $xml_data.'<br>';
}
?>