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