Class: AXML::XMLParser

Inherits:
Object
  • Object
show all
Extended by:
AXML
Defined in:
lib/axml/xmlparser.rb

Direct Known Subclasses

Parser

Defined Under Namespace

Classes: Parser

Constant Summary

Constants included from AXML

CLASS_MAPPINGS, DEFAULTS, PREFERRED, WARN

Class Method Summary collapse

Methods included from AXML

parse, parse_file, xml?

Class Method Details

.parse_io(io, opts = DEFAULTS) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/axml/xmlparser.rb', line 9

def parse_io(io, opts=DEFAULTS)
  parser = AXML::XMLParser::Parser.new
  if opts[:keep_blanks] == false
    parser.set_no_keep_blanks
  end
  if ti = opts[:text_indices]
    if ti.is_a?(Array) && ti.size > 1
      raise NotImplementedError, "currently only supports a single element"
    else
      ti = 
        if ti.is_a?(Array)
          ti.first.to_s
        else
          ti.to_s
        end
      parser.set_single_text_indices(ti)
    end
  end
  parser.parse(io)
  parser.root
end

.parse_string(arg, opts = DEFAULTS) ⇒ Object



31
32
33
# File 'lib/axml/xmlparser.rb', line 31

def parse_string(arg, opts=DEFAULTS)
  parse_io(arg, opts)
end