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. C#
  4. How to write Newlines in XmlDocument

How to write Newlines in XmlDocument

Scheduled Pinned Locked Moved C#
questionxmltutorial
4 Posts 3 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.
  • J Offline
    J Offline
    Jordanwb
    wrote on last edited by
    #1

    I'm trying to write a XmlDocument like so: XmlDocument doc = new XmlDocument(); // Xml is added StreamWriter s = new StreamWriter("output.xml"); XmlTextWriter w = new XmlTextWriter(s); doc.WriteContentTo (w); w.Flush(); s.Flush(); s.WriteLine(); s.Close(); But it writes all the xml on one line. How do I make it put each node on its own line?

    I P 2 Replies Last reply
    0
    • J Jordanwb

      I'm trying to write a XmlDocument like so: XmlDocument doc = new XmlDocument(); // Xml is added StreamWriter s = new StreamWriter("output.xml"); XmlTextWriter w = new XmlTextWriter(s); doc.WriteContentTo (w); w.Flush(); s.Flush(); s.WriteLine(); s.Close(); But it writes all the xml on one line. How do I make it put each node on its own line?

      I Offline
      I Offline
      Ian Shlasko
      wrote on last edited by
      #2

      Could try the Formatting property of the XmlTextWriter.

      Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

      J 1 Reply Last reply
      0
      • I Ian Shlasko

        Could try the Formatting property of the XmlTextWriter.

        Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

        J Offline
        J Offline
        Jordanwb
        wrote on last edited by
        #3

        That works. Thanks.

        1 Reply Last reply
        0
        • J Jordanwb

          I'm trying to write a XmlDocument like so: XmlDocument doc = new XmlDocument(); // Xml is added StreamWriter s = new StreamWriter("output.xml"); XmlTextWriter w = new XmlTextWriter(s); doc.WriteContentTo (w); w.Flush(); s.Flush(); s.WriteLine(); s.Close(); But it writes all the xml on one line. How do I make it put each node on its own line?

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Enable indenting?

          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