Nokogiri Namespace confusion
Using this snippet of XML:
<?xml version="1.0"?>
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="p9781449617424">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title>Essentials of Health Care Finance开发者_如何转开发</dc:title>
</metadata>
</package>
How would I get the value of the tag dc:title
with Nokogiri?
Use XPath and register the namespace:
doc.xpath('//dc:title', 'dc' => 'http://purl.org/dc/elements/1.1/')
精彩评论