T
TomB
I'm trying to persist configuration information to disk. I'm going crazy.
This is what I've tried.
-------
TextWriter writer=new StreamWriter(xmlLoc);
XmlSerializer x = new XmlSerializer(typeof(IP));
for (int i=0;i<iplist.Count;i++)
{
ip=(IP) iplist;
x.Serialize(writer,ip);
}
writer.Close();
-------
It does write it, and it even looks kind of close. But it's not
right....this is what's output.
<IP xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HostName>www.microsoft.com</HostName>
<CommonName>microsoft</CommonName>
<CurrentStatus>0</CurrentStatus>
<Flag>PingDown</Flag>
<NextPing>2004-03-29T21:46:38.6484525-05:00</NextPing>
</IP><?xml version="1.0" encoding="utf-8"?>
<IP xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HostName>www.google.com</HostName>
<CommonName>Google</CommonName>
<CurrentStatus>0</CurrentStatus>
<Flag>PingDown</Flag>
<NextPing>2004-03-29T21:46:38.6484525-05:00</NextPing>
</IP>
As you can see. It's putting the <?xml version="1.0" encoding="utf-i"?>
line in twice, so I assume that I'm way off here.
All of the tutorials and how-tos talk about creating xsd's and so forth. Is
this correct? As you can see this is not a complicated class-that I'm
trying to persist.
Any help is greatly appreciated.
Tom
This is what I've tried.
-------
TextWriter writer=new StreamWriter(xmlLoc);
XmlSerializer x = new XmlSerializer(typeof(IP));
for (int i=0;i<iplist.Count;i++)
{
ip=(IP) iplist;
x.Serialize(writer,ip);
}
writer.Close();
-------
It does write it, and it even looks kind of close. But it's not
right....this is what's output.
<IP xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HostName>www.microsoft.com</HostName>
<CommonName>microsoft</CommonName>
<CurrentStatus>0</CurrentStatus>
<Flag>PingDown</Flag>
<NextPing>2004-03-29T21:46:38.6484525-05:00</NextPing>
</IP><?xml version="1.0" encoding="utf-8"?>
<IP xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HostName>www.google.com</HostName>
<CommonName>Google</CommonName>
<CurrentStatus>0</CurrentStatus>
<Flag>PingDown</Flag>
<NextPing>2004-03-29T21:46:38.6484525-05:00</NextPing>
</IP>
As you can see. It's putting the <?xml version="1.0" encoding="utf-i"?>
line in twice, so I assume that I'm way off here.
All of the tutorials and how-tos talk about creating xsd's and so forth. Is
this correct? As you can see this is not a complicated class-that I'm
trying to persist.
Any help is greatly appreciated.
Tom