开发者

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/')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜