On 23 Jul 2004 07:08:27 +0100 in
microsoft.public.dotnet.languages.csharp, Simon Smith
<gh*****@community.nospam> wrote:
If you set the XmlNode.InnerText property to a string containing these
characters it will convert them (e.g. > to >) and convert back when
you read it out. If you set it's InnerXml property then it won't do that
and you then get problems.
When I read an XML file (using node.InnerText), the special characters
get converted. When I'm saving the XML though, no conversions are
being performed. I'm using WriteElementString() as below:
XmlTextWriter tw = new XmlTextWriter("myalbums.xml", null);
tw.WriteStartElement("albumlist");
foreach (CAlbum album in collection) {
tw.WriteStartElement("album");
tw.WriteElementString("title", album.Title); // special
characters will get saved in the XML
tw.WriteElementString("artist", album.Artist);
tw.WriteElementString("year", album.Year.ToString() );
tw.WriteElementString("duration", album.Duration.ToString() );
tw.WriteEndElement();
}
tw.WriteEndElement();
Any further ideas? Thanks.
Roger