Search the web
Sign In
New User? Sign Up
codesnips · Code Snippets
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[C#] Using XmlTextWriter to create an Xml file   Message List  
Reply | Forward Message #30 of 48 |
Using XmlTextWriter to write an Xml file
 
 
using System;
using System.Xml;
using System.Text;
 
public class MainClass
{
 public static void Main(string [] arg)
 {
  // To create an Xml file with the following format
  // <?xml version="1.0" encoding="Windows-1252" standalone="yes"?>
  // <directory>
  //   <files dir="c:\" />
  // </directory>
 
  XmlTextWriter xmlText = new XmlTextWriter("filename.xml", Encoding.Default);
 
  xmlText.Formatting = Formatting.Indented;
 
  xmlText.WriteStartDocument(true);
 
  // If you want to attach an Xsl file with the Xml then uncomment the following 2 lines
  // It actually adds the xml-stylesheet attribute
  // string xslText="type='text/xsl' href='../index.xsl'";
        // xmlText.WriteProcessingInstruction("xml-stylesheet", xslText);
 
  xmlText.WriteStartElement("directory"); // <directory>
 
  xmlText.WriteStartElement("files"); // <files>
 
  xmlText.WriteAttributeString("dir", "c:\\");
  
  xmlText.WriteEndElement(); // </files>
 
  xmlText.WriteEndElement(); // </directory>
 
  xmlText.WriteEndDocument();
 
  xmlText.Close();
 }
}


Sun Mar 9, 2003 9:27 am

laghari78
Offline Offline
Send Email Send Email

Forward
Message #30 of 48 |
Expand Messages Author Sort by Date

Using XmlTextWriter to write an Xml file using System; using System.Xml; using System.Text; public class MainClass { public static void Main(string [] arg) { ...
Nauman Leghari
laghari78
Offline Send Email
Mar 9, 2003
9:31 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help