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. XMLTextWriter

XMLTextWriter

Scheduled Pinned Locked Moved C#
xmltutorialquestion
3 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.
  • K Offline
    K Offline
    Kant
    wrote on last edited by
    #1

    I am using XMLTextWriter like this to write into the XML file. textWriter.WriteStartDocument(); textWriter.WriteStartElement("", "MAIN TAG", ""); textWriter.WriteStartElement("", "TAG", ""); textWriter.WriteString(strTagValue); textWriter.WriteEndElement(); textWriter.WriteEndElement(); textWriter.Flush(); ex:  STUFF Ignore this !, this is to avoid the format. But when I try to add another TAG, it replaces the current TAG. How to append the new tag to the current tag? What I am doing wrong? I want like this:    STUFF    STUFF2 Ignore this !, this is to avoid the format. Don't :beer: and drive.

    M 1 Reply Last reply
    0
    • K Kant

      I am using XMLTextWriter like this to write into the XML file. textWriter.WriteStartDocument(); textWriter.WriteStartElement("", "MAIN TAG", ""); textWriter.WriteStartElement("", "TAG", ""); textWriter.WriteString(strTagValue); textWriter.WriteEndElement(); textWriter.WriteEndElement(); textWriter.Flush(); ex:  STUFF Ignore this !, this is to avoid the format. But when I try to add another TAG, it replaces the current TAG. How to append the new tag to the current tag? What I am doing wrong? I want like this:    STUFF    STUFF2 Ignore this !, this is to avoid the format. Don't :beer: and drive.

      M Offline
      M Offline
      Mark Smithson
      wrote on last edited by
      #2

      Does this work for you? textWriter.WriteStartDocument(); textWriter.WriteStartElement("", "MAIN TAG", ""); textWriter.WriteStartElement("", "TAG", ""); textWriter.WriteString("STUFF"); textWriter.WriteEndElement(); textWriter.WriteStartElement("", "TAG", ""); textWriter.WriteString("STUFF2"); textWriter.WriteEndElement(); textWriter.WriteEndElement(); textWriter.Flush();

      K 1 Reply Last reply
      0
      • M Mark Smithson

        Does this work for you? textWriter.WriteStartDocument(); textWriter.WriteStartElement("", "MAIN TAG", ""); textWriter.WriteStartElement("", "TAG", ""); textWriter.WriteString("STUFF"); textWriter.WriteEndElement(); textWriter.WriteStartElement("", "TAG", ""); textWriter.WriteString("STUFF2"); textWriter.WriteEndElement(); textWriter.WriteEndElement(); textWriter.Flush();

        K Offline
        K Offline
        Kant
        wrote on last edited by
        #3

        It's not like one time saving in the XML file. In fact, in my program when I complete certain activity I want to add that new string (ex: STUFF2, STUFF3)into the XML file. So my question is: Initially like this <> <> STUFF1 <> <> After sometime I want to add new TAG : <> <> STUFF1 <> <> STUFF2 <> <> Don't :beer: and drive.

        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