From: Bob Hutchison Date: 2006-06-29T02:12:00+09:00 Subject: Re: REXML and Excel XML :) Hi, [Sorry if this is a duplicate, something appears to have gone wrong the first time I posted] On Jun 27, 2006, at 9:06 PM, Andrew Gibson wrote: > I set myself the task of being able to parse a random xml file > generated > by Excel 2003 and I'm having odd problems which I can't really > understand. > > ---- Question Setup ---- > Excel defines two element each with their own namespace. I'll > paste the > XML file at the bottom of this message. > > ** notice the top two elements: and > > > When those two elements with their namespaces atrributes are > present, I > can't access any of the lower elements like or , > When I manually delete the namespace attributes, everything works > fine. > In other words: > > @doc.root.elements.each('Worksheet') {} retruns three elements when I > remove the namespace attribute, but nothing when I put it back in. > > ---- Actual Question --- > Is this just a weird instance of XML which REXML doesn't support or > do I > need to be doing some fancy XPath footwork to make it work? XPath footwork. Write: @doc.root.elements.each('ss:Worksheet') {} The prefix 'ss' is defined and equal to the default namespace of the Worksheet element. Cheers, Bob > > cheers and thanks! :) > > Andrew > ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur -- xampl for Ruby --