0 Replies - 658 Views - Last Post: 11 February 2013 - 09:48 AM Rate Topic: -----

#1 regex  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 33
  • Joined: 25-September 12

Parse HTML

Posted 11 February 2013 - 09:48 AM

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;
            }
        }

This post has been edited by regex: 11 February 2013 - 09:57 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1