I would like to remove all attributes from HTML tags, for example
<div class="" style="" >
I have attempted this using HTMLAgilityPack however it seems that SelectNodes will not work
foreach(var eachNode in HtmlDocument.DocumentNode.SelectNodes("//*"))
{
eachNode.Attributes.RemoveAll();
}
How would I make this work in C# for UWP?
As an alternative to SelectNodes("//*")
, you can use Descendants()
which should return the same result :
foreach(var eachNode in HtmlDocument.DocumentNode.Descendants().Where(x => x.NodeType == HtmlNodeType.Element))
{
eachNode.Attributes.RemoveAll();
}