You are here: Re: [PHP] SimpleXML « PHP « IT news, forums, messages
Re: [PHP] SimpleXML

Posted by "Richard Lynch" on 01/19/06 00:52

On Wed, January 18, 2006 3:49 pm, Jay Paulson wrote:
> I'm a noob when it comes to parsing an XML file. I have a really
> simple
> file that I'm getting back from a SOAP service that I need to parse.
> I
> figure SimpleXML would be great! However, I'm having problems getting
> the
> name attribute for each column element. The XML is below along with
> the
> code I'm using to parse it.
>
> $xml = <<<XML
> <resultSet recordCount="3" columnCount="4">
> <record>
> <column name="BUSINESS_UNIT">CE</column>
> <column name="ATTENDANCE">C</column>
> <column name="COUNT(A.EMPLID)">1</column>
> <column name="TO_CHAR(SYSDATE,YYYY-MM-DD)">2006-01-18</column>
> </record>
> <record>
> <column name="BUSINESS_UNIT">CE</column>
> <column name="ATTENDANCE">D</column>
> <column name="COUNT(A.EMPLID)">1</column>
> <column name="TO_CHAR(SYSDATE,YYYY-MM-DD)">2006-01-18</column>
> </record>
> <record>
> <column name="BUSINESS_UNIT">CE</column>
> <column name="ATTENDANCE">E</column>
> <column name="COUNT(A.EMPLID)">5</column>
> <column name="TO_CHAR(SYSDATE,YYYY-MM-DD)">2006-01-18</column>
> </record>
> </resultSet>
> XML;
>
> $xml = simplexml_load_string($xml);
> print_r($xml);
////////> foreach ($xml->record as $record) {

foreach ($xml->record as $key => $record){
echo $key, ": <br />\n";

> list($k, $v) = each($xml->record->$key->attributes());
> echo "{$k} = {$v}<br>";
> echo "{$key} key / {$value} value<hr>";
> }
> }



--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация