module XML
Overview
The XML module allows parsing and generating XML documents.
XML#parse will parse xml from String or io and return xml document as an XML:Node which represents all kinds of xml nodes.
Example:
require "xml"
xml = <<-XML
 <person id="1">
  <firstname>Jane</firstname>
  <lastname>Doe</lastname>
 </person>
XML
document = XML.parse(xml)             # : XML::Node
person = document.first_element_child # : XML::Node?
if person
  puts person["id"] # "1" : String?
  puts typeof(person.children)                       # XML::NodeSet
  person.children.select(&.element?).each do |child| # Select only element children
    puts typeof(child)                               # XML::Node
    puts child.name                                  # firstname : String
    puts child.content                               # Jane : String?
  end
end
  Defined in:
xml.crConstant Summary
- 
        SUBSTITUTIONS = 
{'>' => ">", '<' => "<", '"' => """, '\'' => "'", '&' => "&"} 
Class Method Summary
- .escape(string : String)
 - 
        .parse(io : IO, options : ParserOptions = ParserOptions.default) : Node
        
          
Parses an XML document from io with options into an
XML::Node. - 
        .parse(string : String, options : ParserOptions = ParserOptions.default) : Node
        
          
Parses an XML document from string with options into an
XML::Node. - 
        .parse_html(io : IO, options : HTMLParserOptions = HTMLParserOptions.default) : Node
        
          
Parses an HTML document from io with options into an
XML::Node. - 
        .parse_html(string : String, options : HTMLParserOptions = HTMLParserOptions.default) : Node
        
          
Parses an HTML document from string with options into an
XML::Node. 
Class Method Detail
Parses an XML document from io with options into an XML::Node.
See ParserOptions.default for default options.
Parses an XML document from string with options into an XML::Node.
See ParserOptions.default for default options.
Parses an HTML document from io with options into an XML::Node.
See HTMLParserOptions.default for default options.
Parses an HTML document from string with options into an XML::Node.
See HTMLParserOptions.default for default options.