gsub这个方法还不支持数字为属性值的标签转换……打开rexml文件夹下面的text.rb,找到代码,大概在289行
- def Text::normalize( input, doctype=nil, entity_filter=nil )
- copy = input
- # Doing it like this rather than in a loop improves the speed
- #copy = copy.gsub( EREFERENCE, '&' )
- copy = copy.gsub( "&", "&" )
- ............省略后面的
def Text::normalize( input, doctype=nil, entity_filter=nil )
copy = input
# Doing it like this rather than in a loop improves the speed
#copy = copy.gsub( EREFERENCE, '&' )
copy = copy.gsub( "&", "&" )
............
2种方法
copy=input =》 ruby = input.to_s
2.直接将integer类型转换成string类型
解决!