Module: QuiversTaskrunner::XmlHelper
- Defined in:
- lib/quiverstaskrunner/helpers/xmlhelper.rb
Class Method Summary collapse
- .create_xmlnode(name, original_document, attributes = {}, content = {}) ⇒ Object
- .get_xml(filepath) ⇒ Object
- .overide_xml(filepath, xml) ⇒ Object
Class Method Details
.create_xmlnode(name, original_document, attributes = {}, content = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/quiverstaskrunner/helpers/xmlhelper.rb', line 44 def self.create_xmlnode(name, original_document, attributes={}, content={}) node = Nokogiri::XML::Node.new name, original_document unless attributes.nil? || attributes.empty? attributes.each { |k,v| node[k.to_s] = v } end unless content.nil? || content.empty? node.content = content end return node end |
.get_xml(filepath) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/quiverstaskrunner/helpers/xmlhelper.rb', line 30 def self.get_xml(filepath) xml = nil File.open(filepath, "rb") do |f| xml = Nokogiri::XML(f) end return xml end |
.overide_xml(filepath, xml) ⇒ Object
38 39 40 41 42 |
# File 'lib/quiverstaskrunner/helpers/xmlhelper.rb', line 38 def self.overide_xml(filepath, xml) File.open(filepath, "w") do |f| f.write(xml.to_xml) end end |