I think it shouldn't be hard to do what you need. Whenever you add a tag you can pass along an optional hash which will be the tag's attributes. So for example if you do:
builder = Builder::XmlMarkup.new
xml = builder.person(name: "foo", age: 0 )
Then you will get <person name='foo' age='0'/>
So in a similar way if you build your dynamic attributes as a hash you can use the #tag!
method like the following:
xml = builder.tag!(tag_name, attributes_hash)