I have problems with the Agility Pack.
I get an exception with an empty link when I use this method in HTML that does not contain a specific node. At first he worked, but then he stopped working. This is just a snippet and there are about 10 more foreach loops that select different nodes.
What am I doing wrong?
public string Export(string html) { var doc = new HtmlDocument(); doc.LoadHtml(html); // exception gets thrown on below line foreach (var repeater in doc.DocumentNode.SelectNodes("//table[@class='mceRepeater']")) { if (repeater != null) { repeater.Name = "editor:repeater"; repeater.Attributes.RemoveAll(); } } var sw = new StringWriter(); doc.Save(sw); sw.Flush(); return sw.ToString(); }
source share