XMLTextWriter
-
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. -
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.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();
-
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();
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.