豆瓣的 api http://api.douban.com/book/subject/1220562?apikey=0b41d213de90252421c5763b9bb06f6c 其中有节点形式为
<db:attribute name="isbn10">7543632608</db:attribute>
想问下用 nokogiri 生成 还有 css 解析 xml 应该怎么处理这个":" 解析:
require "open-uri"
require "nokogiri"
doc = Nokogiri::XML(open('http://api.douban.com/book/subject/1220562?apikey=0b41d213de90252421c5763b9bb06f6c'))
puts doc.css("author") #没有问题
puts doc.css("db:attribute") #匹配不到
生成 xml:
require "nokogiri"
builder = Nokogiri::XML::Builder.new do |xml|
xml.root{
xml.db:tag 10 #syntax error, unexpected tINTEGER, expecting '}'
}
end
puts builder.to_xml