我有一个简单的 XML 格式定义
<list>
<tag postion="11" length="12">VALUE_NODE</tag>
<other tag1,tag2 nodes...>
</list>
我有以下课程:
Class List
include ROXML
xml_accessor :tags, :as => [Tag]
end
class Tag
include ROXML
xml_accessor :position, :from => "@position"
xml_accessor :length, :from => "@length"
end
tag1 = Tag.new
tag1.position = "2"
tag1.length = "23"
tag2 = Tag.new
tag2.position = "2"
tag2.length = "23"
tag_list = TagList.new
tag_list.tags = [tag1,tag2]
好的,我可以使用 setter/getter 方法设置所有属性并序列化对象,但是我如何设置 value_node?就像我搜索了很多页面但没有成功。