FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Read records from XML File
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Read records from XML File [message #174372] Thu, 09 June 2011 09:28 Go to next message
Sarah is currently offline  Sarah
Messages: 30
Registered: December 2010
Karma: 0
Member
Hi! I've an URL that returns me an XML file with this structure

<events>
<event>
<title>.dsfdsfd </title>
.....

Ho can I read each item and save in my local DB??

Thank for help me!
Re: Read records from XML File [message #174373 is a reply to message #174372] Thu, 09 June 2011 09:42 Go to previous messageGo to next message
JohnT is currently offline  JohnT
Messages: 16
Registered: April 2011
Karma: 0
Junior Member
On Thu, 09 Jun 2011 02:28:18 -0700, Sarah wrote:

> Hi! I've an URL that returns me an XML file with this structure
>
> <events>
> <event>
> <title>.dsfdsfd </title>
> ....
>
> Ho can I read each item and save in my local DB??
>

Two choices:

1) You can parse the XML file yourself.
You can use regular expressions to extract the data you want to put
into the DB

2) Use the php xml parser functions:
http://uk.php.net/manual/en/book.xml.php

The php xml functions are quite complicated to use, so for a simple XML
file, it may be easier to do it yourself.

Regards
JohnT
Re: Read records from XML File [message #174374 is a reply to message #174372] Thu, 09 June 2011 09:43 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(Sarah)

> Hi! I've an URL that returns me an XML file with this structure
>
> <events>
> <event>
> <title>.dsfdsfd </title>
> ....
>
> Ho can I read each item and save in my local DB??

SimpleXML?

Micha
Re: Read records from XML File [message #174378 is a reply to message #174373] Thu, 09 June 2011 12:27 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 09/06/2011 11:42, JohnT escribió/wrote:
> The php xml functions are quite complicated to use, so for a simple XML
> file, it may be easier to do it yourself.

You haven't parsed XML since PHP/4, have you? ;-P


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: Read records from XML File [message #174382 is a reply to message #174378] Thu, 09 June 2011 13:54 Go to previous messageGo to next message
Sarah is currently offline  Sarah
Messages: 30
Registered: December 2010
Karma: 0
Member
Thanks to all!

Can you make a simple example using simplexml??

I like to know how to read items (and records) and for each record
reads. execute an insert in my DB!

Very thanks for help me!!!
Re: Read records from XML File [message #174384 is a reply to message #174382] Thu, 09 June 2011 14:15 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 09/06/2011 15:54, Sarah escribió/wrote:
> Thanks to all!
>
> Can you make a simple example using simplexml??
>
> I like to know how to read items (and records) and for each record
> reads. execute an insert in my DB!

If you care to see the manual page, you'll find a full section dedicated
to examples:

http://es.php.net/manual/en/simplexml.examples.php


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: me? pl's visit
Next Topic: esytilkc
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 22:58:15 GMT 2024

Total time taken to generate the page: 0.05892 seconds