Jump to content

Pulling XML data


Markb

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/87289-pulling-xml-data/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87289-pulling-xml-data/#findComment-446516
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.