Re: [PHP] simplexml - can it do what I need?

[email protected] (Shawn McKenzie)
Newsgroups php.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.