• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to parse an XML file from a url and add its data in a database?

I can parse an .xml file from a url but there are some complications.
The output it's not formatted so it's hard to read it and I am having a hard time to put the data in my database. The code is below...
        $xmlstr = simplexml_load_file($url);  

I know that 'xmlrpc' library can help me parse the xml file but I don't know what to put in method().

$this->xmlrpc->server($url, 80);

And since I pass the parameters I want in $url do I need to specify something in $request?
$request = array('My Photoblog', 'http://www.my-site.com/photoblog/');


Is there a library to help me manipulate the xml output afterwards and help me insert its data in a database?

XML-RPC is meant more as a system for a Web service (think SOAP or REST.) In other words, requests from the client will be interpreted as code calls on the server. The server will then return the results of the code ran. Not really what you are doing.

PHP has an excellent extension called SimpleXML. It basically maps an XML document to an object that is easy to traverse.


I see you are using SimpleXML already. My advice about XML-RPC still stands and you should follow the documentation for SimpleXML to parse it. See SimpleXML Examples.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.