In <100984FEB15DD511BA9300104B6980760AC36B@EXCHANGE-RIO>, Ricardo Junior
wrote:
> The conversion to plain text mail format changed the correct indent that
> I need.... I'm needing it like this:
>
> <ROOT>
> <LEVEL-1>
> <LEVEL2/>
> </LEVEL-1>
> </ROOT>
>
> Thanks !!!
no need to scream here :)
here's a function, which maybe helps you (it adds indentation to a string
containing xml-stuff)
function get_indented_xml($xml,$instring = " ") {
$xml = preg_replace("/(\>)\n/","$1",$xml);
$xml = preg_replace("/\>\s*\</",">\n<",$xml);
$axml = explode("\n",$xml);
$indent=-1;
$xmls = "";
foreach ($axml as $key => $value) {
if (preg_match("/<[^\/{1}]/",$value)) {
$indent++;
}
if ($indent < 0)
$indent = 0;
$xmls .= str_repeat($instring,$indent);
if (preg_match("/\<\//",$value) ||
preg_match("/\/\>/",$value)|| preg_match("/-->/",$value)) {
$indent--;
}
$xmls .= trim($value)."\n";
}
return $xmls;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]