C# |
Here is an example of what is created after the xmltextwriter is closed:
Code |
I am not sure why the root tag is being written like it is.
Thank you for any help!
C# |
Code |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tina Thomas18 reputationPosted Jul 29, 2010, 3:34 AM EDT
To solve your problem, use
xmlDocument.Load(fileName);
or
you can read the contents of the file and use xmlDocument.LoadXml
StreamReader sw = new StreamReader(fileName);
string sXml= sw.ReadToEnd();
XmlDocument oXDoc = new XmlDocument();
oXDoc .LoadXml(sXml);
Tina Thomas18 reputationPosted Jul 29, 2010, 2:27 AM EDT
Jason6 reputationPosted Jul 29, 2010, 3:05 AM EDT
So from what you are saying, this:
is ok? I thought tags had to have a starting and ending tag. Also what kind of tag is
Here is my Code:
private XmlDocument xmlDocument;
private XmlTextWriter xmlTextWriter;
private string fileName;
public Serialize(string fileName, string startNode)
{
this.fileName = fileName;
xmlDocument = new XmlDocument();
//Check if the file exists so we do not override an existing file
if (!File.Exists(fileName))
{
xmlTextWriter = new XmlTextWriter(fileName, null);
//Add the root node to the document if (startNode != null)
{
}
xmlDocument.LoadXml(fileName);
}
Jason6 reputationPosted Jul 29, 2010, 4:13 AM EDT
I would have thought that it would have created the following:
is the
Tina Thomas18 reputationPosted Jul 29, 2010, 5:32 AM EDT
If there are child nodes however, it has to be in the format
Hope it helps!