CodeIgniter Forums

Full Version: How to parse an XML file from a url and add its data in a database?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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', '');


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

El Forum

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.