Need help for Nokogiri XML parser

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:

-18

0

960

720

0px

%% url-97255 %%

000000

https://example.com/some.jpg

Opening Still

url-97255

_self

Ideally the link tag should be “%% url-97255 %%”.

Any when I use:

doc = Nokogiri::XML(xml)

puts doc.to_xml

That time the HTML entities is not parsing correctly:

	<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:

<P ALIGN=“LEFT”><FONT FACE=“Arial” SIZE=“24” COLOR="#CC0033" LETTERSPACING=“0” KERNING=“0”>Membership Rewards</FONT></P>

Need help

Thank you,

Abhishek Shukla

What is the input you’re feeding it? if the input is malformed, then nokogiri will have to guess at how to fix it.

Fred