tablatronix / sa_dev-getsimple-plugin

Custom Debugging Profiling suite to plugin programmers.
1 stars 0 forks source link

Does not show simpleXml properly #1

Open tablatronix opened 11 years ago

tablatronix commented 11 years ago

Shows empty


$data → obj•14 SimpleXMLElement[13] {
'pubDate' → str•31 'Wed, 16 Jan 2013 11:51:13 -0600'
'title' → obj•25 SimpleXMLElement[0] {}
'url' → obj•20 SimpleXMLElement[0] {}
'meta' → obj•24 SimpleXMLElement[0] {}
'metad' → obj•26 SimpleXMLElement[0] {}
'menu' → obj•27 SimpleXMLElement[0] {}
'menuOrder' → obj•28 SimpleXMLElement[0] {}
'menuStatus' → obj•29 SimpleXMLElement[0] {}
'template' → obj•30 SimpleXMLElement[0] {}
'parent' → obj•31 SimpleXMLElement[0] {}
'content' → obj•32 SimpleXMLElement[0] {}
'private' → obj•33 SimpleXMLElement[0] {}
'author' → obj•34 SimpleXMLElement[0] {}
}
tablatronix commented 10 years ago

This is normal, and probably not fixable. Would need to parse this with my own function and not a native php dumping function.

tablatronix commented 10 years ago

http://www.php.net/manual/en/function.simplexml-load-file.php#73367

To correctly extract a value from a CDATA just make sure you cast the SimpleXML Element to a string value by using the cast operator:


$xml = '<?xml version="1.0" encoding="UTF-8" ?> 
<rss> 
    <channel> 
        <item> 
            <title><![CDATA[Tom & Jerry]]></title> 
        </item> 
    </channel> 
</rss>'; 

$xml = simplexml_load_string($xml); 

// echo does the casting for you 
echo $xml->channel->item->title; 

// but vardump (or print_r) not! 
var_dump($xml->channel->item->title); 

// so cast the SimpleXML Element to 'string' solve this issue 
var_dump((string) $xml->channel->item->title); 

/*
Above will output: 

Tom & Jerry 

object(SimpleXMLElement)#4 (0) {} 

string(11) "Tom & Jerry"
*/
tablatronix commented 8 years ago

Add custom callout, if simplexml object process via recursive and cast all leaves, so I can get strings out.