class Genit::XmlDocument

Open an xml file.

Public Class Methods

open(file) click to toggle source

Public: Open an xml document.

file - Full path String filename.

Returns a Nokogiri::XML document.

# File lib/genit/documents/xml_document.rb, line 16
def self.open file
  begin
    Nokogiri::XML(File.open(file)){|config| config.strict}
  rescue Nokogiri::XML::SyntaxError => ex
    error "Malformed xhtml in file #{file} : #{ex}"
  end
end
open_fragment(file) click to toggle source

Public: Open a fragment of xml document.

file - Full path String filename.

Returns a Nokogiri::XML document.

# File lib/genit/documents/xml_document.rb, line 39
def self.open_fragment file
  string = IO.read file
  Nokogiri::XML.fragment string
end
open_via_haml(file) click to toggle source

Public: Open a (xml) document from a haml file.

file - Full path String filename of haml file.

Returns a Nokogiri::XML document.

# File lib/genit/documents/xml_document.rb, line 29
def self.open_via_haml file
  tmp = Haml::Engine.new(File.open(file).read, :format => :xhtml).render
  Nokogiri::XML(tmp) 
end