Re: SimpleXML: convert xml to text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2010-03-14 at 21:58 +0800, Dasn wrote:

> Hello, I want to convert some xml stuff to simple string using php, say:
> 
> <?php
> 
> $string = <<<XML
> <a> left <foo>center1<ok>ok</ok>center2</foo>right </a>
> XML;
> 
> $xml = simplexml_load_string($string);
> echo $xml;
> ?>
> The code will output "left right" while all the central stuff was lost.
> How should I print it as "left center1 ok center2 right" ?
> 
> Thanks in advance, and please Cc me. :)
> 
> -- 
> Dasn
> 
> 


Can't you just call strip_tags() on the string? As you don't need to
echo any attribute values, I would have thought it would be perfect. As
XML is meant to be well-formed anyway, strip_tags shouldn't cause any
problems with broken or missing closing tags.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux