【发布时间】:2016-06-15 15:36:08
【问题描述】:
我正在使用 HTMLAgilityPack,我正在尝试选择一个带有冒号的元素 ID。
Using Fizzler.Systems.HtmlAgilityPack;
测试#1(未知的伪类)
HtmlNodeSelection.QuerySelectorAll( _htmlDocument.DocumentNode,"#unlocktheinbox:test");
测试 #2(位置 16 处的无效字符。)
HtmlNodeSelection.QuerySelectorAll( _htmlDocument.DocumentNode,"#unlocktheinbox\\:test");
测试#3(无法识别的转义序列)
HtmlNodeSelection.QuerySelectorAll( _htmlDocument.DocumentNode,"#unlocktheinbox\3A test");
测试 #4(位置 16 处的无效字符。)
HtmlNodeSelection.QuerySelectorAll( _htmlDocument.DocumentNode,"#unlocktheinbox\\3A test");
我做错了什么?
原来我查看了 Fizzler 的源代码..
// TODO Support full string syntax!
//
// string {string1}|{string2}
// string1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*\"
// string2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*\'
// nonascii [^\0-\177]
// escape {unicode}|\\[^\n\r\f0-9a-f]
// unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
//
他们还不支持它:(
【问题讨论】:
-
您的第二种和第四种方法都是正确的。我不知道他们为什么会失败。
-
我同意,我认为第二次和第四次尝试也是正确的,但它不适用于 HTMLAgilityPack。
标签: c# css-selectors html-agility-pack fizzler