开发者

Nokogiri Namespace confusion

开发者 https://www.devze.com 2023-03-18 02:45 出处:网络
Using this snippet of XML: <?xml version=\"1.0\"?> <package xmlns=\"http://www.idpf.org/2007/opf\" version=\"2.0\" unique-identifier=\"p9781449617424\">

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

精彩评论

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