I have HTML agility pack modifying some of my html within the umbraco CMS, however umbraco uses some non-standard html-oid (See below)
The problem is after the html agility pack replaces the closing slash with a question mark.
macro tag before html agility pack开发者_运维问答:
<?UMBRACO_MACRO macroAlias="RandomMacroTest" />
macro tag after html agility pack:
<?umbraco_macro macroalias="RandomMacroTest"?>
Any clues how I could get around this? Tell Html Agility pack to ignore this tag? I've looked at it's various options and none of them seem to apply.
Last resort: to go back and re-fix the macro tags with a regex replace, but that seems a bit messy.
Enable the OptionWriteEmptyNodes
option on the document. It should preserve that tag.
var htmlStr = @"<?UMBRACO_MACRO macroAlias=""RandomMacroTest"" />";
var doc = new HtmlDocument
{
OptionOutputOriginalCase = true,
OptionWriteEmptyNodes = true,
};
doc.LoadHtml(htmlStr);
doc.Save(Console.Out);
You will have the output:
<?UMBRACO_MACRO macroalias="RandomMacroTest" />
精彩评论