Compare 2 XML files with libxml-ruby

N

Nadezda Sekret

Hello!

I wrote ruby script, which parse 2 XML files and compare them using
libxml-ruby. If difference is found - puts message about it.
But this script works long. I am new in ruby and don't know how to
change it, maybe someone can help me to improve my script?
I am parsing large XML files. (~30M)
My script is in attachment.

Thank You!

Attachments:
http://www.ruby-forum.com/attachment/4812/diffscript.rb
 
I

Intransition

Hello!

I wrote ruby script, which parse 2 XML files and compare them using
libxml-ruby. If difference is found - puts message about it.
But this script works long. I am new in ruby and don't know how to
change it, maybe someone can help me to improve my script?
I am parsing large XML files. (~30M)
My script is in attachment.

Thank You!

First of a couple of pointers.

* Indent two spaces. That is the Ruby common practice and will make
your code easier to read. (If don't like such shallow indention then
use 4, but please 8 is just too much).
* Post large samples like this to snippets sites such as github's gist
(http://gist.github.com/) it will colorize the output nicely, again
making it easier to read.
* Add some comments to the code to explain what is going on. People
not familiar with libxml-ruby might be able to help if they knew how
XML::Reader worked.

Having said that, you might get better performance if you eliminate
where the two documents are the same, then what is left over will be
their differences. Just a thought.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top