鉴于以下...
HtmlNode myDiv = doc.DocumentNode.SelectSingleNode("//div[@id='someid']");
...生成的myDiv.InnerHtml包含:
<span>...other content I want to consume...</span>
<a href="http://www.somewhere.com" onmousedown="return somefunc('random','parm','values','SHXA213')">Click Me</a>
<span>...and more content I want to consume...</span>
有没有办法不选择锚标签的onmousedown部分?
解决方案
我需要做的是:
HtmlNodeCollection anchors = myDiv.SelectNodes(@"//a[@class='someclass']");
anchors[0].SetAttributeValue("onmousedown", "");
// could have also used anchors[0].Attributes.Remove() or .RemoveAt()