Module: ROXML::XML

Defined in:
lib/roxml/xml/parsers/libxml.rb,
lib/roxml/xml.rb,
lib/roxml/xml/parsers/nokogiri.rb

Overview

:nodoc:all

Class Method Summary (collapse)

Class Method Details

+ (Object) add_cdata(parent, content)



23
24
25
# File 'lib/roxml/xml/parsers/libxml.rb', line 23

def add_cdata(parent, content)
  parent.add_child(Nokogiri::XML::CDATA.new(parent.document, content))
end

+ (Object) add_child(parent, child)



27
28
29
# File 'lib/roxml/xml/parsers/libxml.rb', line 27

def add_child(parent, child)
  parent.add_child(child)
end

+ (Object) add_node(parent, name)



19
20
21
# File 'lib/roxml/xml/parsers/libxml.rb', line 19

def add_node(parent, name)
  add_child(parent, Nokogiri::XML::Node.new(name, parent.document))
end

+ (Object) new_node(name)



15
16
17
# File 'lib/roxml/xml/parsers/libxml.rb', line 15

def new_node(name)
  Nokogiri::XML::Node.new(name, Document.new)
end

+ (Object) parse_file(path)



36
37
38
39
# File 'lib/roxml/xml/parsers/libxml.rb', line 36

def parse_file(path)
  path = path.sub('file:', '') if path.starts_with?('file:')
  parse_io(open(path))
end

+ (Object) parse_io(stream)



40
41
42
# File 'lib/roxml/xml/parsers/libxml.rb', line 40

def parse_io(stream)
  Nokogiri::XML(stream)
end

+ (Object) parse_string(string)



32
33
34
# File 'lib/roxml/xml/parsers/libxml.rb', line 32

def parse_string(string)
  Nokogiri::XML(string)
end

+ (Object) save_doc(doc, path)



44
45
46
47
48
# File 'lib/roxml/xml/parsers/libxml.rb', line 44

def save_doc(doc, path)
  open(path, 'w') do |file|
    file << doc.serialize
  end
end

+ (Object) set_attribute(node, name, value)



7
8
9
# File 'lib/roxml/xml/parsers/libxml.rb', line 7

def set_attribute(node, name, value)
  node[name] = value
end

+ (Object) set_content(node, content)



11
12
13
# File 'lib/roxml/xml/parsers/libxml.rb', line 11

def set_content(node, content)
  node.content = content
end