From: Gavin Kistner Date: 2011-09-05T04:15:11+09:00 Subject: Re: Ruby and XML Welcome to Ruby. I concur with the other post that Nokogiri is even better than REXML. I don't fully understand your goal or the problem you mentioned about siblings. Can you post a small sample XML and the output you'd like to get from it? -- (-, /\ \/ / /\/ On Sep 4, 2011, at 1:02 PM, Bob Aiello wrote: > Hi Everyone, > > I am new to Ruby and trying to use it to parse XML files so that I can verify that name/value pairs in two (or more) XML files are defined consistently > > I have been trying to use the rexml API > http://www.germane-software.com/software/rexml/ > > The website has been down a lot lately and I haven't found too many other sources for information > > Here is a snippet of my code > > require "rexml/document" > include REXML > > file1 = File.new( "test.xml" ) > doc1 = REXML::Document.new file1 > names1 = XPath.each(doc1, "//name") { |e|} > values1 = XPath.each(doc1, "//value") { |e|} > now I can parse names1 and values1 and then do the same for the second XML file. > This approach is not great because it does ensure that the name/value pairs are siblings. > > I am wondering if there is a better way to do this. > > Any help would be great appreciated. BTW - I would welcome articles on using Ruby for configuration, release and deployment management on CM Crossroads (www.cmcrossroads.com) > > Bob Aiello > http://www.linkedin.com/in/BobAiello > bob.aiello@ieee.org