KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Clearly I need to (a) convert both strings to canonical XML or (b) compare their parse-trees. The following doesn't work because the document object returned doesn't have a sensible == defined. Nokogiri.XML(doc_a) == Nokogiri.XML(doc_b) Nor does the following, because Nokogiri's to_xml leaves some internal whitespace: Nokogiri.XML(doc_a).to_xml == Nokogiri.XML(doc_b).to_xml This is a reasonable approximation of equality (and will work for most cases), but it's not quite right: Nokogiri.XML(doc_a).to_xml.squeeze(' ') == Nokogiri.XML(doc_b).to_xml.squeeze(' ') I'm already using Nokogiri, so I'd prefer to stick with it, but I'll use whatever library works.
Tags (comma-separated)
Save Edits
Cancel