Class: AXML::XMLParser
- Inherits:
-
XMLParser
- Object
- XMLParser
- AXML::XMLParser
- Defined in:
- lib/axml.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
returns the first node found in the document.
Instance Method Summary collapse
- #character(data) ⇒ Object
- #endElement(name) ⇒ Object
-
#initialize ⇒ XMLParser
constructor
takes opts from AXML::parse method.
- #set_no_keep_blanks ⇒ Object
-
#set_single_text_indices(el_name) ⇒ Object
returns text as an array for each occurence of the specified element: [start_index, num_bytes].
- #startElement(name, attributes) ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object
returns the first node found in the document
266 267 268 |
# File 'lib/axml.rb', line 266 def root @root.child end |
Instance Method Details
#character(data) ⇒ Object
325 326 327 |
# File 'lib/axml.rb', line 325 def character(data) @cur.text << data end |
#endElement(name) ⇒ Object
329 330 331 |
# File 'lib/axml.rb', line 329 def endElement(name) @cur = @cur.parent end |
#set_no_keep_blanks ⇒ Object
270 271 272 273 274 275 276 277 278 279 |
# File 'lib/axml.rb', line 270 def set_no_keep_blanks instance_eval do def endElement(name) unless AXML::NotBlankText_re.match(@cur.text) @cur.text = nil end @cur = @cur.parent end end end |
#set_single_text_indices(el_name) ⇒ Object
returns text as an array for each occurence of the specified element: [start_index, num_bytes]
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/axml.rb', line 282 def set_single_text_indices(el_name) @el_name = el_name instance_eval do def startElement(name, attributes) text = if name == @el_name ; [] else ; '' end new_el = ::AXML::El.new(@cur, name, attributes, text, []) @cur.add_node(new_el) @cur = new_el end def character(data) if @cur.text.is_a? Array @cur.text << byteIndex else @cur.text << data end end def endElement(name) if @cur.text.is_a? Array @cur.text << (byteIndex - @cur.text.first) end @cur = @cur.parent end end end |