diff --git a/lib/oga/xml/element.rb b/lib/oga/xml/element.rb index 2a91bcd..6126867 100644 --- a/lib/oga/xml/element.rb +++ b/lib/oga/xml/element.rb @@ -211,7 +211,7 @@ module Oga # @return [String] # def to_xml - ns = namespace ? "#{namespace}:" : '' + ns = namespace_name ? "#{namespace_name}:" : '' body = children.map(&:to_xml).join('') attrs = '' diff --git a/spec/oga/xml/element_spec.rb b/spec/oga/xml/element_spec.rb index 416e4a0..6723654 100644 --- a/spec/oga/xml/element_spec.rb +++ b/spec/oga/xml/element_spec.rb @@ -315,6 +315,16 @@ describe Oga::XML::Element do instance.to_xml.should == '
' end + + example 'generate the corresponding XML when using a default namespace' do + namespace = Oga::XML::Namespace.new(:name => 'xmlns', :uri => 'foo') + instance = described_class.new( + :name => 'foo', + :namespaces => {'xmlns' => namespace} + ) + + instance.to_xml.should == '