This project has moved and is read-only. For the latest updates, please go here.
1
Vote

OptionWriteEmptyNodes leads to wrong form tags

description

Hi,

If I load a HTML-Document with the OptionWriteEmptyNodes set to true, all form elements are rendered selfclosing even if they contain input fields.

The following code demonstrates the problem:
    public class Program
    {
        private static void Main(string[] args)
        {
            string html = 
@"

    
        
            Test
        
    

";

            HtmlDocument doc = new HtmlDocument();
            doc.OptionWriteEmptyNodes = true;
            doc.LoadHtml(html);

            Console.WriteLine(doc.DocumentNode.OuterHtml);

            doc = new HtmlDocument();
            doc.OptionWriteEmptyNodes = false;
            doc.LoadHtml(html);

            Console.WriteLine(doc.DocumentNode.OuterHtml);
            Console.ReadKey();
        }
    }
The above code generates the following output:

        
                
                        Test
                
        




        
                
                        Test
                
        
This behavior is also mentioned (including a fix) in this discussion http://htmlagilitypack.codeplex.com/discussions/7121 but there seems to be no Issue for it.

Thanks for your Help
Cheers Meini

comments