[development] trouble destructing xml

David Metzler metzler.dl at gmail.com
Fri Mar 25 04:58:56 UTC 2011

Regarding introspection..... Not quite true.  I use print_r on simplexml objects all the time with dsm. 

drupal_set_message('<pre>' . print_r($xml,1) . '</pre>'); 

although it sounds like the drupal community is pretty "down" on its use.   I found it useful because it gave a lot of these xml as an object functions long before the other libraries mentioned were around.  Using DOM to iterate hierarchical xml is just silly, as it will take youi twice as many lines of code to do pretty much anything. 

The other thing most people don't know is you can get the interior text of a simplexml element with a simple string cast.   (string)$node. 

The iterators are exactly what makes it useful. 

FYI: The xpath mehod of simplexml would've solved the users problem with the straight property access. 

I'll start giving qp a look , but this community has frowned on bundling third party libraries with drupal contrib modules in the past.  Have we changed our mind regarding this one?  I no

On Mar 24, 2011, at 8:13 PM, Scott Reynen wrote:

> On 3/24/11 7:09 PM, jeff at ayendesigns.com wrote:
>> When I use dsm() on the results, for example, in the case of the object
>> with simplexml I get only one 'that' and do not get its contents.
> It looka like you've already found the XML data you're looking for, but it might be useful for future reference to know that SimpleXML doesn't play well with object inspection such as dsm():
> http://www.php.net/manual/en/simplexmlelement.children.php
> "Note: SimpleXML has made a rule of adding iterative properties to most methods. They cannot be viewed using var_dump() or anything else which can examine objects."
> So the data was in your SimpleXML; you just couldn't see it with dsm().
> -- 
> Scott Reynen
> MakeDataMakeSense.com

More information about the development mailing list