Module: Calligraphy::XML::Utils
Overview
Miscellaneous XML convenience methods.
Instance Method Summary collapse
-
#xml_for(body:, node:) ⇒ Object
Returns the XML for a given XML body and node/CSS selector.
Instance Method Details
#xml_for(body:, node:) ⇒ Object
Returns the XML for a given XML body and node/CSS selector.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/calligraphy/xml/utils.rb', line 8 def xml_for(body:, node:) xml = Nokogiri::XML body return :bad_request unless xml.errors.empty? namespace = nil xml.root.namespace_definitions.each do |n| namespace = "#{n.prefix}|" if dav_namespace n end node = node.split(' ').map! { |n| namespace + n }.join(' ') if namespace xml.css(node).children end |