XML declaration of a XML document or file is very important. We can add XML declaration and create XML element programmatically .
We are using "XDocument" and "XDeclaration" class to add declaration.
Here is example for this.
In this example we create XML document with specified XML declaration and save it into the StringWriter object. You can see in the debug time screenshot.
C#. Net Example :
VB.Net Examples :
Output :
We are using "XDocument" and "XDeclaration" class to add declaration.
Here is example for this.
In this example we create XML document with specified XML declaration and save it into the StringWriter object. You can see in the debug time screenshot.
C#. Net Example :
XDocument doc = new XDocument(new XDeclaration("1.0", "UTF-16", "Yes"),new XElement("Products")); StringWriter sw = new StringWriter(); doc.Save(sw); Response.Write(sw.ToString());
VB.Net Examples :
Dim doc As New XDocument(New XDeclaration("1.0", "UTF-16", "Yes"), New XElement("Products")) Dim sw As New StringWriter() doc.Save(sw) Response.Write(sw.ToString())
Output :
(To view original image , click on image) |
nice tips...excellent stuff...regular reader
ReplyDeletemake habit of these tips...daily