且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Nokogiri 获取具有命名空间的属性值

更新时间:2023-11-24 17:05:04

require 'nokogiri' 

doc = Nokogiri::XML(File.open(path))
  doc.xpath('//jc').each do |n|
    puts n.attr('val')
  end

应该可以.不要忘记查看文档:http://nokogiri.org/tutorials/searching_a_xml_html_document.html#fn:1

Should work. Don't forget to look at the docs : http://nokogiri.org/tutorials/searching_a_xml_html_document.html#fn:1