You must Sign In to post a response.
  • Category: XML

    I have a problem in insert DOCTYPE element in XmlDocument in c#

    How to insert DOCTYPE element in XmlDocument in c#
  • #763370
    Are you using "XmlWriter"

    If you are using "XmlWriter". you can use function
    "WriteDocType" in the "XmlWriter" object.

    By Nathan
    Direction is important than speed

  • #763375
    Hello Manisha,

    If you have problem with the code while inserting DOCTYPE element in XmlDocument then it will be better to share your code with us to help you in better way.

    If you don't know how to add DOCTYPE Element in XmlDocument then refer the below sample code :

    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
    ns.Add("", "");

    var stringwriter = new System.IO.StringWriter();
    using (XmlWriter writer = XmlWriter.Create(stringwriter))
    {
    writer.WriteDocType("service or class name", "string value", "string value", null);
    var serializer = new XmlSerializer(typeof(myService)); // type of can be anything like class, service, dataset, etc.
    serializer.Serialize(writer, obj, ns); // obj can be anything like object of class or service
    }
    var str = stringwriter.ToString();

    Hope this will be helpful for you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #763411
    thank you so much .. :)


  • Sign In to post your comments