Jump to content

XML Search Widget


pontifex

Recommended Posts

I'm trying to make a search widget from this (CAUTION PROCESSOR INTENSIVE) resource.  As you can see, it's (apparently) XML - from the tags at the top and the general form - but my test widget code doesn't show any tags being processed by the parser.

 

Output from 'phpinfo()':

 

'PHP Version 4.3.11'

 

Pretty old, so I'm messing around with fopen() and similar functions.  Code:

 

<?php

function open_tag_handler ($parser, $name, $attributes) {
         print 'Opening Tag '.$name."<br />";
}

function close_tag_handler ($parser, $name) {
         print 'Closing tag '.$name."<br />";
}

#complete later after initial test <---
function tag_content_handler ($parser, $data) {
}

#creating parser
if (! ($xml_parser = xml_parser_create()) ) {
   die ("Cannot create parser");
}

xml_set_element_handler($xml_parser, 'open_tag_handler', 'close_tag_handler');

xml_set_character_data_handler($xml_parser, 'tag_content_handler');

$wowhead_XML = 'http://armory.worldofwarcraft.com/search.xml?fl%5Bsource%5D=dungeon&fl%5Bdungeon%5D=dungeons&fl%5Bdifficulty%5D=normal&fl%5Btype%5D=armor&fl%5BusbleBy%5D=all&fl%5Bslot%5D=all&fl%5BsubTp%5D=all&fl%5BrqrMin%5D=&fl%5BrqrMax%5D=&fl%5Brrt%5D=all&advOptName=defenseRating&advOptOper=gt&advOptValue=0&advOptName=dodgeRating&advOptOper=gt&advOptValue=0&advOptName=parryRating&advOptOper=gt&advOptValue=0&fl%5Bandor%5D=or&searchType=items&fl%5BadvOpt%5D=defenseRating_gt_0&fl%5BadvOpt%5D=dodgeRating_gt_0&fl%5BadvOpt%5D=parryRating_gt_0';

$file_pointer;
$content = '';

if (! ($file_pointer = fopen($wowhead_XML, 'rb'))) {
   die('Cannot open '.$wowhead_XML.' for reading'."<br />");
}

while (!feof($file_pointer)) {
      $content .= fread($file_pointer, 8192);
}

fclose($file_pointer);

if (!xml_parse ($xml_parser, $content) ) {
   $reason = xml_error_string(xml_get_error_code($xml_parser));
   $reason .= xml_get_current_line_number($xml_parser);
   die($reason);
}

xml_parser_free($xml_parser);
?>

 

No errors.  It just doesn't print anything.  I theorize I might be hitting a hard limit on the source string ($wowhead_XML variable above), which is huge.  Any thoughts?

 

--Pontifex

Link to comment
https://forums.phpfreaks.com/topic/59040-xml-search-widget/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.