Class: AXML::LibXML

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

Overview

if using AXML::LibXML, LibXML::XML::Node behavior is slightly modified from the default LibXML behavior:

1. there are no 'text' nodes.  Some nodes have text, some do not
2. :text? returns true if the node has text (in LibXML this returns true
if the node *is* a text node)
3.  text

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 = {}) ⇒ Object

beware that threading with different :keep_blanks values could cause problems since this is a global Libxml setting



25
26
27
# File 'lib/axml/libxml.rb', line 25

def parse_io(io, opts={})
  parse_it(:io, io, opts)
end

.parse_it(method, arg, opts = {}) ⇒ Object



17
18
19
20
21
# File 'lib/axml/libxml.rb', line 17

def parse_it(method, arg, opts={})
  opts = AXML::DEFAULTS.merge opts
  XML::Parser.default_keep_blanks = opts[:keep_blanks] if opts.key?(:keep_blanks)
  XML::Parser.send(method, arg).parse.root
end

.parse_string(string, opts = {}) ⇒ Object

beware that threading with different :keep_blanks values could cause problems since this is a global Libxml setting



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

def parse_string(string, opts={})
  parse_it(:string, string, opts)
end