Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing this XML feed using PHP
    primarykey
    data
    text
    <p>I have an xml feed at this <a href="http://www.supashare.net/test.xml" rel="nofollow noreferrer">url</a></p> <p>Now im trying parse the content, particularly the content in <code>&lt;REDIRECT&gt;&lt;/REDIRECT&gt;</code> tags. I use the following code to try and parse the content but it isnt working and im not sure what im doing wrong.</p> <pre><code>$xml_file = $ADurl; $xml_headline_key = "*XML*RESULTS*LISTING*REDIRECT"; $xml_description_key = "*XML*RESULTS*LISTING*REDIRECT"; $story_array = array(); $counter = 0; class xml_story{ var $headline, $description; } function startTag($parser, $data){ global $current_tag; $current_tag .= "*$data"; } function endTag($parser, $data){ global $current_tag; $tag_key = strrpos($current_tag, '*'); $current_tag = substr($current_tag, 0, $tag_key); } function contents($parser, $data){ global $current_tag, $xml_headline_key, $xml_description_key, $counter, $story_array; switch($current_tag){ case $xml_headline_key: $story_array[$counter] = new xml_story(); $story_array[$counter]-&gt;headline = $data; break; case $xml_description_key: $story_array[$counter]-&gt;description = $data; $counter++; break; } } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "contents"); $fp = fopen($xml_file, "r") or die("Could not open file"); $data = fread($fp, 1024) or die("Could not read file"); 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); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload