From: "Hammond, Tony (ELSLON)" Date: 2002-10-12T01:46:46+09:00 Subject: Re: REXML & Root Node Matt: Sorry to be late in replying. What I meant was leading space before the document (aka root:) element, and after the XML decl. as in the example below. Original mail attached below which lists two separate case - two separate errors. % cat tmp.xml % test-rexml /usr/local/lib/ruby/site_ruby/1.6/rexml/document.rb:234:in `parse': attempted adding second root element to document (REXML::ParseException) Could you copy me on any reply? Thanks, Tony ps/ Using REXML version 2.5.2. -----Original Message----- From: Matt Gushee [mailto:mgushee@havenrock.com] Sent: 07 October 2002 17:53 To: ruby-talk@ruby-lang.org Subject: Re: REXML & Root Node On Tue, Oct 08, 2002 at 01:38:05AM +0900, Hammond, Tony (ELSLON) wrote: > > I'm getting errors from REXML with leading whitespace when I have an XML > Declaration - see below. (Problem doesn't show up when I omit the > Declaration.) Any ideas? Could you be a little more precise about what you mean by 'leading whitespace'? If it's whitespace before the XML declaration, you should be getting an error ... although I don't get an error either with or without the whitespace. What version of REXML are you using (I'm using 2.5.1)? > Also I'm not quite sure why the document element is returned by the root > method. Surely the root node is the outermost container which wraps document > element, PI's, XML Declaration, whitespace, etc.? Sure ... but the root method returns the root *element*, which is another name for the document element. I guess whether that's intuitive or not is in the eye of the beholder (it is for me), but since, for all practical purposes, the root *node* is equivalent to the document object, why would you need a method to get it anyway? -- Matt Gushee Englewood, Colorado, USA mgushee@havenrock.com http://www.havenrock.com/ Hi: I'm getting errors from REXML with leading whitespace when I have an XML Declaration - see below. (Problem doesn't show up when I omit the Declaration.) Any ideas? Also I'm not quite sure why the document element is returned by the root method. Surely the root node is the outermost container which wraps document element, PI's, XML Declaration, whitespace, etc.? Thanks for any insights, Tony % cat test-rexml #!/usr/local/bin/ruby require 'rexml/document'; include REXML doc = Document.new File.new('tmp.xml') % test-rexml /usr/local/lib/ruby/site_ruby/1.6/rexml/document.rb:234:in `parse': attempted a ding second root element to document (REXML::ParseException) % cat tmp.xml % test-rexml /usr/local/lib/ruby/site_ruby/1.6/rexml/element.rb:686:in `base_parser': malfor ed XML: missing tag start (REXML::ParseException) % cat tmp.xml