Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5838597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:29:05+00:00 2026-05-22T11:29:05+00:00

Clearly I need to (a) convert both strings to canonical XML or (b) compare

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:29:06+00:00Added an answer on May 22, 2026 at 11:29 am

    If you are looking for structural equality and don’t care about the order of tags and attributes, probably the xml-simple library is a good choice. It converts the xml into ruby’s data structures (hashes and lists) which can be safely compared with the == operator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you are calling a function, where there's clearly a need to break down
Hi I shall try to explain clearly what I need to be able to
As title says need to convert a Zip file to text file , no
I have a varchar column which contains date in following format dd/mm/yyyy I need
For some reason I need to cast/convert a DateTime into one of many custom
I'm clearly in need of improving my knowledge in this Java field, or I'm
I need to work with several data samples, to say, N . The samples
I need to convert a number into an unsigned byte. The number is always
Clearly, when GROUP BY clause used, columns that are not aggregate function should be
This is clearly not appears like it wouldn't be a best practice. Can someone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.