Jump to content

dpace32

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dpace32's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for the quick reply - I tried this but it is still displaying all the data and now it is wrapping array around the output. I think this part is producing the output: function stop($parser, $element_name){ //echo 'e' . $element_name . 'e'; switch($element_name){ case "RED": // this is the tag that is after the end of the stated set of data, complete and execute the query here - // code to build the whole query statement and your mysql_query() goes here ... print_r($this->current); // contains the values for [TRIP], [PLATFORM], and [iNFORMATIONTYPE] echo "<br />"; break; default: } How do I filter this so it only shows where INFORMATIONTYPE = FAST and only display the Trip and the InformationType? Thank you again.
  2. Hello - First time poster and pretty new to PHP. I have tried to research this before posting but I couldn't find any tutorials with this exact scenario. I am trying to create a PHP file that reads an XML file with the following layout: <Root> - <Vehicle="Red"> <Trip>1108</Trip> <Platform>123RFIES</Platform> <InformationType>Slow</InformationType> </Red> - <Vehicle="Red"> <Trip>1108</Trip> <Platform>123RSHAS</Platform> <InformationType>Fast</InformationType> </Red> I am using the following PHP: <?php $file = "Vehicle.xml"; function contents($parser, $data){ echo $data; } function startTag($parser, $data){ echo "<b>"; } function endTag($parser, $data){ echo "</b><br />"; } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "contents"); $fp = fopen($file, "r"); $data = fread($fp, 80000); if(!(xml_parse($xml_parser, $data, feof($fp)))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } xml_parser_free($xml_parser); fclose($fp); ?> Using this code I can read the entire XML and display it on the webpage. What I am trying to do is filter it so it only displays when InformationType = Fast and only display the Trip and the InformationType. Where do I add this filter logic? Thank you in advance! -Adam
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.