libxml default namespace
Can’t find your nodes? Neither could we. So it turns out that Xpath doesn’t behave well with default namespaces. This is what Corey and I figured out…hope it helps.
Example XML
<Response xmlns=”http://www.badpopcorn.com/solutions”>
<solutions>
<solution>Don’t got any</solution>
<solutions>
</Response>
Although you can load it into a document, you can’t find any nodes without a little hack (using the word little loosely). Ruby example.
doc = XML:Document.file(’http://badpopcorn.com/file.xml’)
dn = ‘dn: http://www.badpopcorn.com/solutions’
doc.find(’//dn:solutions’,dn).each do |node|
r = node.find(”dn:solution,dn).first.content
Yea, we know how you feel. Way to go Corey.
Posted in Life Stuff
![[del.icio.us]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/digg.png)
![[Google]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/google.png)
![[StumbleUpon]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Windows Live]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://badpopcorn.com/blog/wp-content/plugins/bookmarkify/email.png)
No Comments »
No comments yet.
RSS feed for comments on this post. | TrackBack URI
Leave a comment