using XML as a datasource

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

using XML as a datasource

Post by bdee1 »

i was wondering what is the simplest way to use XML as a datasource for a php app. can someone please point me in the right direction?

i basically want to build a simple little app that will store a list of links - each with a title, url and description. the user will be able to add new links and edit existing ones via the app. and i was thinking it might be best to store this information in an xml file rather than a db since its such a small and simpel data structure.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: using XML as a datasource

Post by kendall »

It really depends on you the developer and what can work for you. PHP 5 xml parsing has gotten a bit efficient so you could explore it. The use of XML as a datasource is usually best when using data across platforms.
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: using XML as a datasource

Post by bdee1 »

sorry i am pretty new to PHP so I am still tryign to figure out all the options available to me.

i have been toying with SimpleXML

is that what you mean when you say PHP5 xml parsing? or is there something different?
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: using XML as a datasource

Post by kendall »

:wink: yip
bdee1
Forum Newbie
Posts: 10
Joined: Wed Jan 14, 2009 12:18 pm

Re: using XML as a datasource

Post by bdee1 »

ok so heres a question...

using SimpleXML, is there any easy way to query a node?

so for instance lets say i have the following xml file:

Code: Select all

 
<library>
     <book id="1">
          <title>Yellow River</title>
          <title>I.P. Freely</title>
     </book>
     <book id="2">
          <title>Eyeglasses</title>
          <title>Seymour Clearly</title>
     </book>
</library>
 
and i wanted to find the book node with an id attribute of 2. is there a quick way to just query for that, liek with a database? or do i need to loop through the book nodes and on each iteration test to see if the id=1?
Post Reply