Re: simplexml - can it do what I need?

From: Date: Sat, 06 Feb 2010 17:24:20 +0000
Subject: Re: simplexml - can it do what I need?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-301851@lists.php.net to get a copy of this message
TerryA wrote: > My first post and I'm just a few days into learning PHP so that I can extract > data from an XML feed for updating a MySQL driven website. Simplexml grabs > most of my data without a problem but I can't get at the data in elements > such as: > <element idtype="11" lang="fr" label="Description - > Etage"><![CDATA[Rez de > jardin]]></element> > <element idtype="1" lang="fr" label="Description - Nombre de > pièces"><![CDATA[1]]></element> > <element idtype="2" lang="fr" label="Description - Nombre de > chambres"><![CDATA[0]]></element> > <element idtype="3" lang="fr" label="Description - Surface totale > (m²)"><![CDATA[27]]></element> > I have around a hundred of these elements but only need data from two of > them. I need to extract the CDATA by specifying the idtype and lang > attribute. For example, in the first of these elements, I need to be able to > get out the string "Rez de jardin" by specifying idtype="11" and > lang="fr". > Can I use Simplexml to do this and, if so, how? If not, what should I use? > Many thanks for any help. > Terry Look at the options: $xml = simplexml_load_file('file.xml', 'SimpleXMLElement', LIBXML_NOCDATA); -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#301851) next »