I'm using using Nokogiri to parse an html snippet so that I can remove
empty attributes.
clean_me = "<div id=\"something\" class=\"\" style=\"\"><fb:like
show_faces=\"true\" width=10\"></fb:like></div>"
parsed = Nokogiri::HTML::DocumentFragment.parse(clean_me)
self.clean_empty_child_attributes(parsed)
parsed.to_html
The problem I am having is that the 'fb:' is removed and the width=10
gets foobared so the result looks something like this:
"<div id=\"something\"><like show_faces=\"true\"></like>10\"></
div>"
On Apr 14, 2011 9:30 PM, "Justin" <justi...@gmail.com> wrote:
>
> Thanks Mike. Your solution works perfectly. I was originally hoping
> that nokogiri would clean up the bad html - width=10" - but it makes
> sense that it returns an error.
This is a shortcoming in libxml2: the in-context fragment parser does not correct markup. Ordinarily libxml2 handles this sort of thing just fine.
> --
> You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
> To post to this group, send email to nokogi...@googlegroups.com.
> To unsubscribe from this group, send email to nokogiri-tal...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nokogiri-talk?hl=en.
>