Module: XmlUtils

Defined in:
lib/xmlutils/node.rb,
lib/xmlutils/xpath.rb,
lib/xmlutils/xml_doc.rb,
lib/xmlutils/tokenizer.rb,
lib/xmlutils/formatters.rb,
lib/xmlutils/tree_parser.rb

Overview

Copyright © 2024 Manticore Authors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <www.gnu.org/licenses/>.

Defined Under Namespace

Classes: Attribute, CData, ChildNode, Comment, DocType, Document, Element, Formatters, IllegalArgumentError, Node, ParseException, ProcessingInstruction, Text, Token, Tokenizer, TreeParser, UndefinedNamespaceException, XMLDecl, XPath

Constant Summary collapse

VERSION =
"3.0.1"

Class Method Summary collapse

Class Method Details

.create_element(name, attributes = {}) ⇒ Object



32
33
34
35
36
# File 'lib/xmlutils/xml_doc.rb', line 32

def self.create_element(name, attributes = {})
  element = Element.new(name)
  attributes.each { |k, v| element.add_attribute(k, v) }
  element
end

.new_documentObject



28
29
30
# File 'lib/xmlutils/xml_doc.rb', line 28

def self.new_document
  Document.new
end

.parse(source) ⇒ Object



23
24
25
26
# File 'lib/xmlutils/xml_doc.rb', line 23

def self.parse(source)
  parser = TreeParser.new(source)
  parser.parse
end

.to_xml_string(node) ⇒ Object



38
39
40
41
42
43
# File 'lib/xmlutils/xml_doc.rb', line 38

def self.to_xml_string(node)
  formatter = Formatters::Default.new
  output = ""
  formatter.write(node, output)
  output
end