Thread

Posted on Fri Sep 1 18:02:29 2006 by tszming
Remove linefeed from XML
hi, is it possible to remove linefeed, cr or tab from XML elements' content automatically using Twig, rather than using RE as it is quite slow for large document. i don't know if `expat` provided this function already or not. i.e.
use XML::Twig; my $xml = qq{ <people> <name>tom</name> <description>test 123 2 2</description> </people> }; my $twig= new XML::Twig( discard_spaces_in => ['description'], TwigHandlers => { people => \&people } ); $twig->parse($xml); sub people { my( $twig, $people)= @_; print $people->first_child( 'description')->text; # i don't want \n\r\t ! }
Thanks.
Direct Responses: 2893 | Write a response
Posted on Fri Sep 1 19:01:26 2006 by mirod in response to 2890
Re: Remove linefeed from XML
You can use the trimmed_text method instead of text (but it uses a regexp too, so the speed will be the same, expat doesn't provide any help for this).
Direct Responses: 2894 | Write a response
Posted on Fri Sep 1 19:23:55 2006 by tszming in response to 2893
Re: Remove linefeed from XML
Thanks.
Write a response