Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Parse HTML

$
0
0
I have a template editor page in a .net MVC application.

I want it to parse HTML and than display the proper styling on a save.

Should I use HTML agility pack?
What is some C# code for the button save to initiate the parse? How do I pass the user defined HTML to the save method within the controller?

Would one example be (In TemplateController):

 public void Save()
        {
            HtmlDocument document = new HtmlDocument();
            string htmlString = "<html>blabla</html>";
            document.LoadHtml(htmlString);
            HtmlNodeCollection collection = document.DocumentNode.SelectNodes("//a");
            foreach (HtmlNode link in collection)
            {
                string target = link.Attributes["href"].Value;
            }
        }

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>