Hi,

I have a string like "\n <div> attrib1=\"test\"</div>"

I want to pass this as parameter to xmldocument.loadXML();

I received an exception when I tried to pass the above string.

Please suggest me to proceed.

Thanks in Advance

Recommended Answers

All 2 Replies

What exception? Invalid XML?

I received an exception when I tried to pass the above string.

What exception did you get and which version of the .NET framework are you compiling against? This works for me on .NET 3.5:

using System;
using System.Xml;

public class Program
{
    public static void Main()
    {
        try
        {
            var doc = new XmlDocument();

            doc.LoadXml("\n <div> attrib1=\"test\"</div>");

            Console.WriteLine(doc.OuterXml);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.