類別
會在使用 SAX 事件解析 XML 文件時建立 hash。
方法
- C
- E
- S
常數
CONTENT_KEY | = | "__content__" |
HASH_SIZE_KEY | = | "__hash_size__" |
屬性
[R] | hash |
執行個體公開方法
current_hash() 連結
end_document() 連結
end_element(名稱) 連結
error(錯誤訊息) 連結
start_document() 連結
start_element(名稱,屬性 = []) 連結
來源: 顯示 |
# File activesupport/lib/active_support/xml_mini/nokogirisax.rb, line 41
def start_element(name, attrs = [])
new_hash = { CONTENT_KEY => +"" }.merge!(Hash[attrs])
new_hash[HASH_SIZE_KEY] = new_hash.size + 1
case current_hash[name]
when Array then current_hash[name] << new_hash
when Hash then current_hash[name] = [current_hash[name], new_hash]
when nil then current_hash[name] = new_hash
end
@hash_stack.push(new_hash)
end