On Tue, Jul 5, 2011 at 4:36 PM, Kanishka <kanishkanihal@xxxxxxxxx> wrote: > hi this is my first post on php general mailing list, i want to read a xml > file to retrieve data. i tried by using "DOM" and "simple xml" but i > couldn't. > the xml file looks like this.. > > *<note> > <head> > <title>the the title</title> > <date>7-6-2011</date> > </head> > > <data> > <book> > <name>book 1</name> > <author>author 1</author> > </book> > > <book> > <name>book 2</name> > <author>auther 2</author> > </book> > > </data> > </note>* > > i want to put both "name" and "author" values in a multy dimensional array. > what dimension is suitable? what should i do for resolve my problem? <?php $data =<<<END <note> <head> <title>the the title</title> <date>7-6-2011</date> </head> <data> <book> <name>book 1</name> <author>author 1</author> </book> <book> <name>book 2</name> <author>auther 2</author> </book> </data> </note> END; $xml = simplexml_load_string($data); $arr = array(); foreach ($xml->data->book as $book) { $arr[] = array('name' => (string)$book->name, 'author' => (string)$book->author); } var_dump($arr); ?> -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/