Ruby on Rails Wednesday, February 25, 2015

Hi,

I am facing issue with the Nokogiri XML Parser:

I am using the following code to parse:

doc = Nokogiri::HTML.fragment(xml)
puts doc.to_xml

Output:
<image>
<x>-18</x>
<y>0</y>
<width>960</width>
<height>720</height>
<borderwidth>0px</borderwidth>
<link />%% url-97255 %%
<bordercolor>000000</bordercolor>
<caption>Opening Still</caption>
<linktype>url-97255</linktype>
<linktarget>_self</linktarget>
</image>

Ideally the link tag should be "<link>%% url-97255 %%</link>". 

Any when I use:
doc = Nokogiri::XML(xml)
puts doc.to_xml

That time the HTML entities is not parsing correctly:
<richtext>
<x>331</x>
<y>183</y>
<width>508</width>
<height>44</height>
<richmailmerge/>
<usedarkbg>false</usedarkbg>
<borderColor>000000</borderColor>
<usebgcolor>false</usebgcolor>
<richtext-textfield>P ALIGN=LEFTFONT FACE=Arial SIZE=24 COLOR=#CC0033 LETTERSPACING=0 KERNING=0Thi - Creativs ise/FONT/P</richtext-textfield>
<borderWidth>0px</borderWidth>
<backgroundcolor>000000</backgroundcolor>
<richtext/>
</richtext>
 
Instead I was hoping that I will get output something like:
<richtext-textfield>&lt;P ALIGN="LEFT"&gt;&lt;FONT FACE="Arial" SIZE="24" COLOR="#CC0033" LETTERSPACING="0" KERNING="0"&gt;Membership Rewards&lt;/FONT&gt;&lt;/P&gt;</richtext-textfield>

Need help

Thank you,
Abhishek Shukla

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAFwSd-s32KDkvD5oW4fzTE%2Bg2rPPSKmXpEUnYGiGZC%3DKWtda_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment