[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Parsing XML: always 'syntax error'

gtcc2009

1/13/2006 8:43:00 PM

Hi there,
I'm trying to parse a document using the code from the book The Ruby
Way. And the program always output 'syntax error in line 1', I have
tried with a non-exist xml file, an existing but invalid formatted one
and an existing and valid formatted one. All have the same outputs. The
xml file is in the same folder with the ruby file.

require 'xmltreebuilder'
def setup_dom(path)
builder = XML::DOM::Builder.new(0)
builder.setBase(".") # have tried ./ has well
begin
puts path
xmltree = builder.parse(path, true)
rescue XMLParserError => err
line = builder.line
print "#{ $0} : #{ $!} (in line #{ line} )\n"
exit 1
end
xmltree.documentElement.normalize
return xmltree
end

Can anyone help me with this?

Thanks,

Dor