Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl converting some html entities when I don't want it to

by daxim (Chaplain)
on Sep 13, 2012 at 11:01 UTC ( #993450=note: print w/ replies, xml ) Need Help??


in reply to Perl converting some html entities when I don't want it to

Your problem is the lack of entity-decoding in line 17 of your program.

This works:

use strictures; use HTML::Entities qw(decode_entities); use XML::LibXML qw(); my $xml = XML::LibXML->load_xml(string => <<'XML'); <root> <NODE id="431" text="&lt;P align=&amp;quot;left&amp;quot;&gt;Non-mortg +age&amp;amp;nbsp;debts is yes&lt;/P&gt;" type="DataInput" contextstri +ng="OtherPriorityDebts" group next="True" branchValue="Yes" dataDe +faultV="Yes" dataVisible="False" /> </root> XML for my $node ($xml->findnodes('//NODE')) { my $text = $node->getAttribute('text'); # <P align=&quot;left&quot;>Non-mortgage&amp;nbsp;debts is yes</P> my $html = decode_entities $text; # <P align="left">Non-mortgage&nbsp;debts is yes</P> }


Comment on Re: Perl converting some html entities when I don't want it to
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993450]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-12-27 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls