note 95578 modified in simplexmlelement.children by thiago

From: Date: Mon, 11 Jan 2010 11:41:02 +0000
Subject: note 95578 modified in simplexmlelement.children by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164847@lists.php.net to get a copy of this message
use this If you want to view the HTML as well as data. normal dumps display the parsed versions of HTML. This code displays the HTML as Text in a Text Area, and also display all other a data along side as an array perfect for debugging (xml with html). Try This Code: <?php $xml = simplexml_load_file($url); function xml2array_parse($xml){ foreach ($xml->children() as $parent => $child){ $return["$parent"] = xml2array_parse($child)?xml2array_parse($child):"$child"; } return $return; } print "<pre><textarea style=\"width:200%;height:100%;\">"; print_r(xml2array_parse($xml)); print "</textarea></pre>"; ?> --was-- use this If you want to view the HTML as well as data. normal dumps display the parsed versions of HTML. This code displays the HTML as Text in a Text Area, and also display all other a data along side as an array perfect for debugging (xml with html). Try This Code: $xml = simplexml_load_file($url); function xml2array_parse($xml){ foreach ($xml->children() as $parent => $child){ $return["$parent"] = xml2array_parse($child)?xml2array_parse($child):"$child"; } return $return; } print "<pre><textarea style=\"width:200%;height:100%;\">"; print_r(xml2array_parse($xml)); print "</textarea></pre>"; http://php.net/manual/en/simplexmlelement.children.php

« previous php.notes (#164847) next »