HTML Agility to extract PHP tags

ε祈祈猫儿з 提交于 2019-12-23 22:18:13

问题


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 (invalid token).

Tried escaping ? with ?? and \?

Thanks


回答1:


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?



来源:https://stackoverflow.com/questions/3445490/html-agility-to-extract-php-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!