The code can explain this problem much better than I can. I also included alternative methods that I was trying to do. If possible, explain why these other methods also do not work. I ran out of ideas, and, unfortunately, there are few examples for HtmlAgilityPack. I am currently looking through the documentation looking for more ideas.
One thing I noticed is the .nextSibling property, and I thought I could use the while loop to go through the form until I find the next sibling or the end of the form.
Anyway, here is the code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using HtmlAgilityPack; using System.Collections; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string source = @" <form name='form1' action='action1' method='method1' id='id1'> <input type='text1.1' name='name1.1' value='value1.1' /> <input type='text1.2' name='name1.2' value='value1.2' /> </form> <form name='form2' action='action2' method='method2' id='id2'> <input type='text2.1' name='name2.1' value='value2.1' /> <input type='text2.2' name='name2.2' value='value2.2' /> </form> "; List<HtmlAttribute> formAttributes = new List<HtmlAttribute>();
html-parsing html-agility-pack
Codygman
source share