Closed nruth closed 1 year ago
The post is corrupted though, looks like a software change adjusted the open/close tag rules and stuff is getting swallowed and generally coming out wrong.
https://web.archive.org/web/20120508013729/https://tenderlovemaking.com/2009/04/23/namespaces-in-xml/ is more complete
I'm looking at this because the nokogiri docs on how to work with parsed xml seem to be missing something: they start searching for car and bike namespaces, but those keywords aren't in the xml anywhere.
Pinging @tenderlove in case he wants to fix the blog post.
@nruth I'm not sure I understand what you're saying about the docs. This ruby code from the docs:
@doc = Nokogiri::XML(File.read("parts.xml"))
car_tires = @doc.xpath('//car:tire', 'car' => 'http://alicesautoparts.com/')
# => ["<tire>all weather</tire>",
# "<tire>studded</tire>",
# "<tire>extra wide</tire>"]
bike_tires = @doc.xpath('//bike:tire', 'bike' => 'http://bobsbikes.com/')
# => ["<tire>street</tire>", "<tire>mountain</tire>"]
is making the point that you can name the namespace in the query whatever you want -- it's the URI that needs to match. make sense?
fixes blog post link 404