How do I add script Body's on Load with Html Agility Pack

Topics: Developer Forum
Apr 20, 2011 at 8:39 AM

How do I add script Body's on Load using Html Agility Pack like below example.

Ex:

before html.:

<body class="..." onLoad="...;">    .....</body>

after add:
<body class="..." onLoad="...;added script;">    .....</body>
Apr 21, 2011 at 9:53 PM

Try this:

var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(someHtml);

var body = htmlDoc.DocumentNode.SelectSingleNode("//body");
body.Attributes["onLoad"].Value += "added script;";