开发者

HTML Agility to extract PHP tags

开发者 https://www.devze.com 2023-01-10 17:40 出处:网络
What syntax should be used with HTML Agility Pack to extract all Tags from a Php file..? HtmlNodeCollection tags = htmlDoc.DocumentNode.SelectNodes(\"//??php\");

What syntax should be used with HTML Agility Pack to extract all

Tags from a Php file..?

HtmlNodeCollection tags = htmlDoc.DocumentNode.SelectNodes("//??php");

Throws an exception (开发者_Go百科invalid token).

Tried escaping ? with ?? and \?

Thanks


HTML Agility Pack does choke on nodes with ? in the name. The simplest option is probably to go through the HTML string before you load it into a document object and replace instances of <? with <php and so-on. That doesn't handle any nasty cases like having a string literal on the page with "&lt?" but really, how often does that happen?

0

精彩评论

暂无评论...
验证码 换一张
取 消