CultureInfo implements IFormatProvider. You don't need the
".NumberFormat".
I did try it by in the XML File I am creating I always get the comma
and not the not.
Here is my entire code:
MemoryStream stream = new MemoryStream();
// Define settings
var settings = new XmlWriterSettings {
Encoding = new UTF8Encoding(false),
ConformanceLevel = ConformanceLevel.Document,
Indent = true
};
// Open writer
XmlWriter writer = XmlWriter.Create(stream, settings);
writer.WriteStartElement("urlset", "
http://www.sitemaps.org/
schemas/sitemap/0.9");
writer.WriteWhitespace(Environment.NewLine);
// Fill write
foreach (SitemapUrl u in Urls) {
writer.WriteStartElement("url");
writer.WriteElementString("loc", u.Location);
writer.WriteElementString("lastmod", u.Updated.ToString("yyyy-
MM-dd"));
writer.WriteElementString("changefreq",
u.ChangeFrequency.ToString().ToLower());
writer.WriteElementString("priority", String.Format("{0:0.0}",
(Double)u.Priority, CultureInfo.InvariantCulture));
writer.WriteEndElement();
writer.WriteWhitespace(Environment.NewLine);
}
// Close writer
writer.WriteWhitespace(Environment.NewLine);
writer.WriteEndElement();
writer.Flush();
// Define content
StringBuilder content = new StringBuilder();
content.Append(Encoding.UTF8.GetString(stream.ToArray()));
return content.ToString();
Check the priority ... I am trying to create string with only one
decimal from the double.
I get always the comma on the XML file.
If i just use a string "0.4" then it works fine ...
Any idea?
Thanks,
Miguel