Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. reading xml file and write it into text file in C#

reading xml file and write it into text file in C#

Scheduled Pinned Locked Moved XML / XSL
csharpxmlhelptutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adiveppanavar
    wrote on last edited by
    #1

    hi friends... i am reading xml file but i am not able to write it in .txt file. so please help me how to do it. and i am using c#.net i want read xml file and generate xyz.txt file thanks manohar manohar

    L 1 Reply Last reply
    0
    • A adiveppanavar

      hi friends... i am reading xml file but i am not able to write it in .txt file. so please help me how to do it. and i am using c#.net i want read xml file and generate xyz.txt file thanks manohar manohar

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      adiveppanavar wrote:

      but i am not able to write it in .txt file.

      Post the code that you are having trouble with and explain specifically what happens, what is wrong, what the problem is. Also read this[^]. Pay attention to item #2.

      led mike

      A 1 Reply Last reply
      0
      • L led mike

        adiveppanavar wrote:

        but i am not able to write it in .txt file.

        Post the code that you are having trouble with and explain specifically what happens, what is wrong, what the problem is. Also read this[^]. Pay attention to item #2.

        led mike

        A Offline
        A Offline
        adiveppanavar
        wrote on last edited by
        #3

        string file = "D:\\sampleXML2.xml"; XmlTextReader reader = new XmlTextReader(file); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: Console.WriteLine(reader.Value); break; } FileStream stream = new FileStream("D:\\manohar.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(stream); sw.WriteLine(reader.Value); sw.Close(); stream.Close(); } Console.WriteLine("Enter Any Key"); Console.ReadLine(); }

        L 1 Reply Last reply
        0
        • A adiveppanavar

          string file = "D:\\sampleXML2.xml"; XmlTextReader reader = new XmlTextReader(file); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: Console.WriteLine(reader.Value); break; } FileStream stream = new FileStream("D:\\manohar.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new StreamWriter(stream); sw.WriteLine(reader.Value); sw.Close(); stream.Close(); } Console.WriteLine("Enter Any Key"); Console.ReadLine(); }

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          XmlDocument doc = new XmlDocument();
          doc.Load("..\\..\\NavData.xml");
          StreamWriter sw = new StreamWriter("MyData.txt");
          XmlNodeList nodes = doc.SelectNodes("//text()");
          foreach (XmlNode n in nodes)
          sw.WriteLine(n.Value);

          sw.Flush();
          sw.Close();

          led mike

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups