Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 04, 2012 09:37 AM by tusharrs
Member
205 Points
349 Posts
May 04, 2012 09:15 AM|LINK
Hai,
can anyone pls tell me how to write this line "<?xml version="1.0" encoding="utf-8"?>" and Root Node <Record></Record> in xml file dynamically.Pls tell any solution.Thanks in Advance
Contributor
4289 Points
883 Posts
May 04, 2012 09:19 AM|LINK
Please refer this article.
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx
3230 Points
668 Posts
May 04, 2012 09:26 AM|LINK
using System.Xml; public partial class Default13 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); // XML declaration XmlNode declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(declaration); // Root element: article XmlElement root = doc.CreateElement("Record"); root.InnerText = "This is root element"; doc.AppendChild(root); doc.Save(Server.MapPath("~\\temp.xml")); } }
hi,
Star
7625 Points
1454 Posts
May 04, 2012 09:29 AM|LINK
XmlWriter writer = XmlWriter.Create("Record.xml")) writer.WriteStartDocument(); writer.WriteStartElement("Record"); //Write all node writer.WriteEndElement(); writer.WriteEndDocument();
May 04, 2012 09:32 AM|LINK
Hai tusharrs,
Thanks for u r rply.I have created XML File dynamically using this code:
XmlTextWriter writer = new XmlTextWriter("E:\\WebSite1\\product.xml",Encoding.UTF8);
After that,i need to write XML Declaration and Root Node.Can u pls tell me how to do this.
May 04, 2012 09:37 AM|LINK
when you create xml file create it with root node and xml declaration and then save it
i have posted the code
smanjula
Member
205 Points
349 Posts
Write in XML File Dynamically
May 04, 2012 09:15 AM|LINK
Hai,
can anyone pls tell me how to write this line "<?xml version="1.0" encoding="utf-8"?>" and Root Node <Record></Record> in xml file dynamically.Pls tell any solution.Thanks in Advance
Srikanth Kas...
Contributor
4289 Points
883 Posts
Re: Write in XML File Dynamically
May 04, 2012 09:19 AM|LINK
Please refer this article.
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
tusharrs
Contributor
3230 Points
668 Posts
Re: Write in XML File Dynamically
May 04, 2012 09:26 AM|LINK
using System.Xml; public partial class Default13 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); // XML declaration XmlNode declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(declaration); // Root element: article XmlElement root = doc.CreateElement("Record"); root.InnerText = "This is root element"; doc.AppendChild(root); doc.Save(Server.MapPath("~\\temp.xml")); } }hi,
( Mark as Answer if it helps you out )
View my Blog
santosh.jagd...
Star
7625 Points
1454 Posts
Re: Write in XML File Dynamically
May 04, 2012 09:29 AM|LINK
XmlWriter writer = XmlWriter.Create("Record.xml")) writer.WriteStartDocument(); writer.WriteStartElement("Record"); //Write all node writer.WriteEndElement(); writer.WriteEndDocument();MCP
smanjula
Member
205 Points
349 Posts
Re: Write in XML File Dynamically
May 04, 2012 09:32 AM|LINK
Hai tusharrs,
Thanks for u r rply.I have created XML File dynamically using this code:
XmlTextWriter writer = new XmlTextWriter("E:\\WebSite1\\product.xml",Encoding.UTF8);
After that,i need to write XML Declaration and Root Node.Can u pls tell me how to do this.
tusharrs
Contributor
3230 Points
668 Posts
Re: Write in XML File Dynamically
May 04, 2012 09:37 AM|LINK
when you create xml file create it with root node and xml declaration and then save it
i have posted the code
( Mark as Answer if it helps you out )
View my Blog