Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function foundAnOpeningTag($parser,$tag)
- {
- global $inOrigin, $inDestination;
- if($tag=="ORIGIN")
- {
- $inOrigin = true;
- }
- elseif($tag=="DESTINATION")
- {
- $inDestination = true;
- }
- }
- // Function to handle closing tags.
- function foundAClosingTag($parser,$tag)
- {
- global $inOrigin, $inDestination;
- if($tag=="ORIGIN")
- {
- $inOrigin = false;
- }
- elseif($tag=="DESTINATION")
- {
- $inDestination = false;
- }
- }
- // Function to handle characters within tags.
- function foundSomeText($parser,$characters)
- {
- global $inOrigin, $inDestination;
- global $traindata;
- if($inOrigin)
- {
- $traindata["origins"][] = $characters;
- }
- elseif($inDestination)
- {
- $traindata["destinations"][] = $characters;
- }
- }
- // Parse the XML.
- $parser = xml_parser_create();
- xml_set_element_handler($parser, "foundAnOpeningTag","foundAClosingTag");
- xml_set_character_data_handler($parser, "foundSomeText");
- xml_parse($parser,$response);
- xml_parser_free($parser);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement