问题
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 "<?" but really, how often does that happen?
来源:https://stackoverflow.com/questions/3445490/html-agility-to-extract-php-tags