Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a node with a default namespace stores it as 'no-namespace' in the parent #134

Closed
david opened this issue Sep 9, 2009 · 2 comments

Comments

@david
Copy link

david commented Sep 9, 2009

This works:

doc = Nokogiri::XML("<element><child xmlns="woop:de:doo" /></element>")
doc.at("//xmlns:child", 'xmlns' => 'woop:de:doo') #=> <child xmlns="woop:de:doo" />

This doesn't:

doc = Nokogiri::XML::Document.new
e = Nokogiri::XML::Node.new('element', doc)
c = Nokogiri::XML::Node.new('child', doc)
c.add_namespace(nil, 'woop:de:doo')
e.add_child(c)
doc.add_child(c)

doc.at("//xmlns:child", 'xmlns' => 'woop:de:doo') #=> nil
@david
Copy link
Author

david commented Sep 9, 2009

I'd also like to add that if you have a document like this:

<element>
  <c1 xmlns="one" />
  <c2 xmlns="two" />
</element>

then

doc.root.collect_namespaces.inspect #=> {'xmlns' => 'two'}

@tenderlove
Copy link
Member

Yup. That is the danger of collect_namespaces. I think that method should be removed.

The first problem is fixed here: c6e5fa0

flavorjones pushed a commit that referenced this issue Apr 7, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants