using xml within yii

Hi,

I’m just trying to read back an xml file using basic PHP functions but have had no luck. The xml file sits in the data folder and I will need to update this file from the website.

Could someone point me in the right direction of the best way to read, parse and use XML within Yii? Are there any clever extensions out there?

Bit of a Yii newbie so sorry if this is a daft question

Thanks,

G

you could use a builtin php class simpleXML: http://php.net/manual/en/book.simplexml.php

If you need to amend the xml file itself then you would need to use something more advanced such as XML DOM: http://php.net/manual/en/book.domxml.php

for example of each visit the links.

hope this helps you get started

Hi,

Thanks for that bettor. I’ve been looking at SimpleXML and other PHP functions - I was just hoping that there might be a nice Yii extension out there somewhere that could help :)

G

Using Yii bulid-in database tools (either ActiveRecord or DAO) you can easily retrieve database contents (SQL query result) as associative array. You can then also quite easily (I hope so) convert this array to an XML.

Here you have some resources on this subject (converting PHP array to XML):

Though, I must admit that I haven’t tested them yet (I’m doing this right now)…