Re: Adressing XML Objects
| From: | Andrew Ballard | Date: | Fri, 09 Jan 2009 02:01:08 +0000 |
| Subject: | Re: Adressing XML Objects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285795@lists.php.net to get a copy of this message | ||
On Wed, Jan 7, 2009 at 3:10 PM, Merlin Morgenstern <merlin_x@fastmail.fm> wrote:
> Hi there,
>
> I am justing walking my first steps on XML and PHP. As I learned from a
> tutorial adressing is very simple:
>
> echo $xml->anbieter->immobilie->preise->kaufpreis;
>
> I simply just can't figure out how to adress this structure:
> <anhang location="INTERN" gruppe="TITELBILD">
>
> This does not work:
> echo $xml->anbieter->immobilie->anhaenge->daten->anhanginhalt;
>
> Somehow location and gruppe needs to be placed into the command. I already
> tried a couple of version, but no success.
>
> Thank you for any hint.
>
> Best regards, Merlin
>
I haven't used SimpleXML too much, but aren't you just looking for this?
$attributes =
$xml->anbieter->immobilie->anhaenge->daten->anhanginhalt->anhang->attributes();
echo $attributes['location'], "\n";
echo $attributes['gruppe'], "\n";
http://www.php.net/manual/en/function.simplexml-element-attributes.php
Andrew