Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 imbibing at the Monastery: (8)
As of 2015-07-03 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls