[Mono-list] Differing behaviour of XmlDocument.Save(String) on Linux and Windows

Chris Raine c.raine@gmx.net
Tue, 15 Jun 2004 23:32:44 +0200


--=-ijLiv9QYkByhjJcTImSR
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

I have written a small Xml application which loads an xml file,=20
works on the data and then saves the data write back into the an xml
file.=20

I load a xml file with the following code=20
<verbatim>=20
private static XmlDocument OpenXmlDocument(string sPath)=20
{
 XmlDocument doc =3D new XmlDocument();=20
 XmlTextReader treader =3D new XmlTextReader(sPath);=20
 XmlValidatingReader vreader =3D new XmlValidatingReader(treader);=20
 vreader.ValidationType =3D ValidationType.DTD;=20
 vreader.ValidationEventHandler +=3D new
ValidationEventHandler(ParseError);=20
 doc.Load(vreader);=20
 return doc;=20
}
</verbatim>=20

I then save the Document with the follwing simple line of code=20
<verbatim>
private static void SaveXmlDocument(XmlDocument doc, string sPath)=20
{
  doc.Save(sPath);=20
}
</verbatim>

This code works fine on both windows and linux, spite the fact when the
same filename is given to the loading method and the saving method. On
linux, this works fine, the Save() overwrites the old file with a new
file. On Windows however an exception is thrown telling me a sharing
violation had occured. MS .Net showed the same behaviour, not allowing
me to write to the same file if I had opened it with my load method
above. I do not have the experience of deciding if this is a bug or not
on the mono-linux side, or just a rude programming fault on my side.=20

(OT now, sorry) Does anyone know an elegant way of loading an
XmlDocument and then writing the updated contents back into the same
file?=20

Next to the problem with XmlDocument, if I dump a DateTime Object to a
string with ToString("F") on Linux and read that dumped string back into
a windows box with DateTime.Parse(string) I get an FormatException.=20

DateTime.Now.ToString("F"); produces=20

"June 15, 2004 7:44:07 P +2" on Linux (RH9)=20

and the same produces=20

"June 15, 2004 7:55:07 +2" on Win32 (without the 'P')=20

regards,=20
chris=20


--=-ijLiv9QYkByhjJcTImSR
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQBAzzdxbYsg67DxFJcRAp8/AJ4p80YdRu0za3ELSUhTR9TwflJyKACfV56g
dxGeTZ29FsYrgUixO19akQk=
=g+1W
-----END PGP SIGNATURE-----

--=-ijLiv9QYkByhjJcTImSR--