Module: ParseHelper

Overview

Copyright © 2008-2011 AMEE UK Ltd. - www.amee.com Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.

Instance Method Summary collapse

Instance Method Details

#load_xml_doc(xml) ⇒ Object



41
42
43
44
45
# File 'lib/amee/parse_helper.rb', line 41

def load_xml_doc(xml)
  doc = Nokogiri.XML(xml) { |config| config.strict }
  doc.remove_namespaces!
  doc
end

#node_value(node) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/amee/parse_helper.rb', line 26

def node_value(node)
  if node.is_a?(Nokogiri::XML::Attr) || node.is_a?(REXML::Attribute)
    # Attributes are allowed to be an empty string
    return node.to_s
  elsif node.is_a?(Nokogiri::XML::Element) || node.is_a?(REXML::Element)
    return node.text == '' ? nil : node.text
  else
    return node.to_s
  end
end

#xmlpathpreambleObject



37
38
39
# File 'lib/amee/parse_helper.rb', line 37

def xmlpathpreamble
  ''
end