Markb Posted January 22, 2008 Share Posted January 22, 2008 In the last couple of days i have been trying to pull some XML data from http://www.wowarmory.com/guild-info.xml?r=Jubei%27Thos&n=StRikEfOrCe&p=1. All i want to do is pull every name in the character list and put them in a MYSQL database. i am consider myself good with php mysql and i can easily make info enter the database but i can figure out how to pull all the name in XML. i have been trying the attribute() function but it always comes up in an error. If anyone could help me that would be great thanks. Quote Link to comment https://forums.phpfreaks.com/topic/87289-pulling-xml-data/ Share on other sites More sharing options...
jambroo Posted January 23, 2008 Share Posted January 23, 2008 Just follow examples from http://php.net/xml. You can parse the xml using classes defined in the comments. Quote Link to comment https://forums.phpfreaks.com/topic/87289-pulling-xml-data/#findComment-446504 Share on other sites More sharing options...
Markb Posted January 23, 2008 Author Share Posted January 23, 2008 thats the thing i have used the examples but i come up with the error Fatal error: Call to a member function attributes() on a non-object Quote Link to comment https://forums.phpfreaks.com/topic/87289-pulling-xml-data/#findComment-446506 Share on other sites More sharing options...
jambroo Posted January 23, 2008 Share Posted January 23, 2008 That just means your trying to access the attributes method on an object that doesn't contain that method. Where did you learn about the attributes() method? A tutorial that might be useful to you: http://www.sitepoint.com/article/php-xml-parsing-rss-1-0 Quote Link to comment https://forums.phpfreaks.com/topic/87289-pulling-xml-data/#findComment-446511 Share on other sites More sharing options...
Markb Posted January 23, 2008 Author Share Posted January 23, 2008 ty for the article but used some of their code just to see if it would run: // Create an XML parser $xml_parser = xml_parser_create(); // Set the functions to handle opening and closing tags xml_set_element_handler($xml_parser, "startElement", "endElement"); // Set the function to handle blocks of character data xml_set_character_data_handler($xml_parser, "characterData"); // Open the XML file for reading $fp = fopen("http://www.sitepoint.com/rss.php","r") or die("Error reading RSS data."); // Read the XML file 4KB at a time while ($data = fread($fp, 4096)) // Parse each 4KB chunk with the XML parser created above xml_parse($xml_parser, $data, feof($fp)) // Handle errors in parsing or die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); // Close the XML file fclose($fp); // Free up memory used by the XML parser xml_parser_free($xml_parser); and i came up with the errors: Warning: xml_parse() [function.xml-parse]: Unable to call handler startElement() in /home/exacutio/public_html/frame/strike/test.php on line 37 Warning: xml_parse() [function.xml-parse]: Unable to call handler characterData() in /home/exacutio/public_html/frame/strike/test.php on line 37 Warning: xml_parse() [function.xml-parse]: Unable to call handler startElement() in /home/exacutio/public_html/frame/strike/test.php on line 37 Warning: xml_parse() [function.xml-parse]: Unable to call handler characterData() in /home/exacutio/public_html/frame/strike/test.php on line 37 it makes me think if my webhost is playing up or somthing Quote Link to comment https://forums.phpfreaks.com/topic/87289-pulling-xml-data/#findComment-446516 Share on other sites More sharing options...
jambroo Posted January 23, 2008 Share Posted January 23, 2008 Call the method phpinfo() and it will display all your PHP settings. Is your "DOM/XML" set to enabled? If its not enabled you can just uncomment the line "extension=php_domxml.dll" from your php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/87289-pulling-xml-data/#findComment-446617 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.