I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2006-09-01 15:02:29-07 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 2006-09-01 16:01:26-07 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 2006-09-01 16:23:55-07 by tszming in response to 2893
Re: Remove linefeed from XML
Thanks.
Direct Responses: Write a response