class Nokogiri::XML::Document
Public Instance Methods
add_node_under_css_selector(css_selector, node)
click to toggle source
# File lib/quiverstaskrunner/helpers/xmlhelper.rb, line 6 def add_node_under_css_selector(css_selector, node) nodes = node.is_a?(Array) ? node : [node] self.css(css_selector).each { |n| nodes.each { |x| n.add_child(x) } } end
update_node_at_css_selector(css_selector, attributes={}, content={})
click to toggle source
# File lib/quiverstaskrunner/helpers/xmlhelper.rb, line 11 def update_node_at_css_selector(css_selector, attributes={}, content={}) attribute_exists = !attributes.nil? && attributes.any? content_exists = !content.nil? && content.any? self.css(css_selector).each { |n| if attribute_exists attributes.each { |k,v| n[k.to_s] = v} end if content_exists n.content = content end } end