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
No Comments »
No comments yet.
RSS feed for comments on this post. | TrackBack URI
Leave a comment