[BUG?] NoMethodError in REXML::Xpath.match in Ruby 1.9

irb(main):011:0> xml = REXML::Element.new('element > attr="aaa"')
=> <element attr="aaa"/>

That's your problem. Actually, it is my problem; REXML shouldn't allow
you to create an element with a tag name that has illegal characters in
it -- while it does check for illegal characters during parsing, it is
much more liberal when creating tags programmatically, as you're doing
here.

What is happening is that you aren't creating an element named
'element' here -- you're creating an element named 'element
attr="aaa"'. What you want to do is: xml = REXML::Element.new(
'element', {'attr'=>'aaa'} ) or xml = REXML::Element.new( 'element' )
xml.attributes[ 'attr' ] = 'aaa'

--- SER

That's your problem.

Oops... next time I'll try to RTFM more :frowning:
Thanks for the explanation, and sorry for making the noise.

Actually, it is my problem; REXML shouldn't allow
you to create an element with a tag name that has illegal characters in
it

I'm not really sure if this is a good idea or a bad one, but perhaps
this might be a feature? If the tag name passed to the constructor is
not a valid tag name, but is on the other hand a well-formed XML, then
parse it.

Brgds,
Alex

ยทยทยท

On Tue, 2004-08-03 at 21:06, SER wrote: