This is in compliance with the W3C spec on parsing XML. It also comes
into play when a node's content contains both text and tags. However,
given the situation you described, perhaps an accessor method is in
order. Open an enhancement ticket and I'll consider it.
On Apr 28, 8:06 am, MarcS <[EMAIL PROTECTED]> wrote:
> Hi everyone.
>
> I recently upgraded to the most recent version of cake and as expected
> a few things didn't work.
> There is one thing, however, which I really can't work out.
>
> A part of my application is parsing some XML data which looks pretty
> much like this
>
> <sites type='array'>
> <site type='struct'>
> <id>82</id>
> <name>aaaaa</name>
> <url>sdfsdf</url>
> </site>
> <site type='struct'>
> <id>85</id>
> <name>new sites</name>
> <url>newsite.com</url>
> </site>
> <site type='struct'>
> <id>86</id>
> <name>sdfsdf</name>
> <url></url>
> </site>
> </sites>
>
> I then loop through the array like this:
>
> $sites_server_xml =& new
> XML($this->AppSetting->site_exchange_url."/
> getsites{$site_id}.xml");
> $sites_server=array();
> if ($sites_server_xml->hasChildren()) {
> foreach ($sites_server_xml->children[0]->children as
> $node) {
> if($node->name=="site") {
>
> if(!$this->siteExistsLocally($node->child('id')->value,
> $local_sites_to_exclude)) {
> $sites_server[]=array('id' =>
> $node->child('id')->value,
> 'name' =>
> $node->child('name')->value,
> 'url' =>
> $node->child('url')->value == null ? "" : $node->child('url')->value);
>
> }
> }
> }
> }
>
> The problem is that the children of the node 'site' does contain the
> children 'id' 'name' and 'url'
> However, these children all have NULL values but contain another child
> which has the name "#text" and the appropriate value, which means I
> would have to access the values not through $node->child('id')->value
> but $node->child('id')->children[0]->value which doesn't make much
> sense to me.
> Can someone explain this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---