Nokogiri 可以搜索“?xml-stylesheet"吗?标签? [英] Can Nokogiri search for "?xml-stylesheet" tags?
本文介绍了Nokogiri 可以搜索“?xml-stylesheet"吗?标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要解析一个 XML 样式表:
I need to parse for an XML style sheet:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/templates/xslt/inspections/disclaimer_en.xsl"?>
我尝试过使用 Nokogiri:
Using Nokogiri I tried:
doc.search("?xml-stylesheet").first['href']
但我收到错误:
`on_error': unexpected '?' after '' (Nokogiri::CSS::SyntaxError)
推荐答案
Nokogiri 无法搜索作为 XML 处理指令的标签.您可以像这样访问它们:
Nokogiri cannot search for tags that are XML processing instructions. You may access them like this:
doc.children[0]
这篇关于Nokogiri 可以搜索“?xml-stylesheet"吗?标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文