|
Here is an example of what is created after the xmltextwriter is closed:
|
I am not sure why the root tag is being written like it is.
Thank you for any help!
|
|
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tina ThomasPosted Jul 29, 2010, 7:34 AM
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 ThomasPosted Jul 29, 2010, 9:32 AM
If there are child nodes however, it has to be in the format
Hope it helps!
JasonPosted Jul 29, 2010, 8:13 AM
I would have thought that it would have created the following:
is the
JasonPosted Jul 29, 2010, 7:05 AM
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);
}
Tina ThomasPosted Jul 29, 2010, 6:27 AM