Thread: PHP: XML Reader Question
-
08-10-2008 11:02 PM #1
PHP: XML Reader Question
I am trying to grab certain attributes from an xml page. It works fine on my own desktop comp with a localhost server. When I upload to my website, which uses mySQL, it fails. I am new to php and seem to be stuck because it doesn't output an error.
Here is the code: (this was copy/pasted from somewhere on the net and edited by me to fit my needs)
After this, my code grabs the new $item_xxxx variables and inserts them into the database. Even if I try to echo the variables after this XML Reader, they won't show. Again, I have no issues on my home computer with localhost server. Is there something I am missing? Or is there abetter way to do this?Code:$xml = new XMLReader(); $xml->open($new_link); // Declare and open the xml file $xml->setParserProperty(2,true); // This seems a little unclear to me - but it worked :) while ($xml->read()) { echo 'test1'; switch ($xml->name) { case "name": $xml->read(); $conf["name"] = $xml->value; $item_name = $conf["name"]; echo $item_name; $xml->read(); break; case "quality": $xml->read(); $conf["quality"] = $xml->value; $raw_quality = $conf["quality"]; if ($raw_quality == 'Common') $item_quality = 1; elseif ($raw_quality == 'Uncommon') $item_quality = 2; elseif ($raw_quality == 'Rare') $item_quality = 3; elseif ($raw_quality == 'Epic') $item_quality = 4; elseif ($raw_quality == 'Legendary') $item_quality = 5; else $item_quality = 0; $xml->read(); break; case "subclass": $xml->read(); $conf["subclass"] = $xml->value; $item_subclass = $conf["subclass"]; echo $item_subclass; $xml->read(); break; case "inventorySlot": $xml->read(); $conf["inventorySlot"] = $xml->value; $item_slot = $conf["inventorySlot"]; echo $item_slot; $xml->read(); break; case "link": $xml->read(); $conf["link"] = $xml->value; $item_link = $conf["link"]; echo $item_link; $xml->read(); break; echo "$xml->read()"; } } $xml->close();
-
08-10-2008 11:06 PM #2
Re: PHP: XML Reader Question
The user inputs a number, hits submit, the xml reader locates the xml with that number on a certain website. Then it reads it and outputs variables for the php to save.
One thing to note....when on the internet (where it is breaking and not working) it also makes the footer disappear after the user inputs the number and hits submit
-
08-11-2008 08:32 PM #3
Re: PHP: XML Reader Question
Seems I might have an older version. After checking my phpinfo, I have v 4.3.11 through my provider (Yahoo).PHP 5 introduced XMLReader, a new class for reading Extensible Markup Language (XML).
I've emailed them, but expecting the classic response of a 'not at this time' attitude. Any suggestions?
-
08-12-2008 06:13 AM #4
Re: PHP: XML Reader Question
PHP4 is officially end-of-life. Hopefully your provider will upgrade soon.

Diplomacy is the art of saying "good doggie" while looking for a bigger stick.
-
08-12-2008 08:13 PM #5
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)






Reply With Quote




Bookmarks