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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to