lib/exlibris/primo/xml_util.rb in exlibris-primo-1.0.8 vs lib/exlibris/primo/xml_util.rb in exlibris-primo-1.0.9
- old
+ new
@@ -1,10 +1,10 @@
module Exlibris
module Primo
- #
+ #
# Utility for parsing and building XML
- #
+ #
module XmlUtil
require 'nokogiri'
def self.included(klass)
klass.class_eval do
@@ -45,10 +45,22 @@
def xml_without_namespaces
xml.clone.remove_namespaces!
end
protected :xml_without_namespaces
+ def remove_namespaces_from_raw_xml(raw_xml, namespaces)
+ tmp_xml_with_namespaces = build_xml do |xml|
+ xml.root(namespaces) do
+ xml << raw_xml
+ end
+ end
+ tmp_xml = Nokogiri::XML(tmp_xml_with_namespaces)
+ tmp_xml.remove_namespaces!
+ tmp_xml.root.children.first.to_xml(xml_options)
+ end
+ protected :remove_namespaces_from_raw_xml
+
def to_hash
Hash.from_xml(to_xml)
end
def to_xml
@@ -58,6 +70,6 @@
def to_json
to_hash.to_json
end
end
end
-end
\ No newline at end of file
+end