我需要解析 XML 样式表:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/templates/xslt/inspections/disclaimer_en.xsl"?>
我尝试过使用 Nokogiri:
doc.search("?xml-stylesheet").first['href']
但是我得到了错误:
`on_error': unexpected '?' after '' (Nokogiri::CSS::SyntaxError)
最佳答案
Nokogiri 无法搜索作为 XML 处理指令的标签。您可以像这样访问它们:
doc.children[0]
关于ruby - Nokogiri 可以搜索 "?xml-stylesheet"标签吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3542264/