Page 1 of 1

using XML as a datasource

Posted: Wed Jan 14, 2009 2:06 pm
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.

Re: using XML as a datasource

Posted: Wed Jan 14, 2009 2:18 pm
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.

Re: using XML as a datasource

Posted: Wed Jan 14, 2009 2:22 pm
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?

Re: using XML as a datasource

Posted: Wed Jan 14, 2009 2:56 pm
by kendall
:wink: yip

Re: using XML as a datasource

Posted: Wed Jan 14, 2009 5:04 pm
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?