Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Debugging SimpleXML Objects (See related posts)

AGRH@!! SimpleXML bites the big one -- you can't even var_dump it to examine the contents and the controls are terrible. Luckily, you can convert it for debugging:

$sxml = simplexml_load_string($data);
// .. much hate between then and now... //
debugsxml($sxml);


function debugsxml($sxml) {
    $dom = dom_import_simplexml($sxml);
    printArray($dom);
}

function printArray($array){
    echo '<pre>';
    print_r($array);
    echo '</pre>';
}



You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts