found this in the forums and it at least counts the number of elements, however I am not understanding how to change it so I can get it to work properly.
<?php
$compiled_langs = array();
$interprt_langs = array();
$flag = "";
$count = 0;
function opening_element($parser, $element, $attributes) {
/ opening XML element callback function /
global $flag;
if ($element == "id")
$flag = $attributes["value"];
}
function closing_element($parser, $element) {
/ closing XML element callback function /
global $flag;
if ($element == "view")
$flag = "id";
}
function character_data($parser, $data) {
/ callback function for character data /
global $flag;
if ($flag == "id") {
global $compiled_langs;
$compiled_langs[] = $data;
}
if ($flag == "value") {
global $interprt_langs;
$interprt_langs[] = $data;
}
}
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($parser, "opening_element", "closing_element");
xml_set_character_data_handler($parser, "character_data");
$document = file("http://www.guild-wars.us/xmlfeed.txt");
foreach ($document as $line) {
xml_parse($parser, $line);
}
xml_parser_free($parser);
echo "The following compiled languages were found...<br />";
foreach ($compiled_langs as $name) {
$count++;
echo "$count. $name <br />";
}
echo "<br />";
$count = 0;
echo "The following interpreted languages were found...<br />";
foreach ($interprt_langs as $name) {
$count++;
echo "$count. $name <br />";
}
?>
any help would be greatly appreciated.