Tagbuilder Find Specific Inner Element And Add New Attribute
I have a TagBuilder which contains Outer and Inner Elements. How do I traverse to the Input level line , and Add the following as an New attribute? placeholder='Search'
Solution 1:
For your task you can use HtmlAgilityPack.
Using HtmlAgilityPack you can use XPath Query to select necessary nodes and add tag to this node.
To select nodes you can use SelectNodes method:
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);
var nodes = htmlDoc.DocumentNode.SelectNodes("//input[contains(@class, 'focusedOut')]");
To add attribute you can use Attributes Collection:
node.Attributes.Add("placeholder","Search");
Post a Comment for "Tagbuilder Find Specific Inner Element And Add New Attribute"