File: libxml.rb

package info (click to toggle)
ruby-multi-xml 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 216 kB
  • sloc: ruby: 1,231; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'libxml' unless defined?(LibXML)
require 'multi_xml/parsers/libxml2_parser'

module MultiXml
  module Parsers
    module Libxml #:nodoc:
      include Libxml2Parser
      extend self

      def parse_error
        ::LibXML::XML::Error
      end

      def parse(xml)
        node_to_hash(LibXML::XML::Parser.io(xml).parse.root)
      end

    private

      def each_child(node, &block)
        node.each_child(&block)
      end

      def each_attr(node, &block)
        node.each_attr(&block)
      end

      def node_name(node)
        node.name
      end
    end
  end
end