> .NET 2.0
>
[quoted text clipped - 12 lines]
>
> any suggestions on how to fix this?
Use Decimal.Parse, passing in CultureInfo.InvariantCulture, e.g.
decimal _value = decimal.Parse(reader.GetAttribute("value"),
CultureInfo.InvariantCulture);
Jon
Not tested, but perhaps:
reader.MoveToAttribute("value");
reader.ReadContentAsDecimal();
Marc
> I'm parsing an XML file and read an attribute value out of a node. This
> value ( value="0.0000") am I trying to convert to a decimal:
...
> any suggestions on how to fix this?
Jon is right, CultureInfo.InvariantCulture is the solution in this case.
Because the thing is in an XML, it should be locale-independent.
So make sure to always use CultureInfo.InvariantCulture, both to
create the XML and to read it.
And you have to do the same not only for numbers, but also for dates and
times (and convert them to UTC times), if you have any such data.

Signature
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Marc Gravell - 12 Jan 2008 09:42 GMT
Actually, just glancing through the object library - there is a
wrapper that encapsulates all the xml rules for the different types
(it is used internally by XmlReader) - XmlConvert.
i.e.
decimal _value = XmlConvert.ToDecimal(reader.GetAttribute("value"));
Not only does this make it clear that you are talking about xml
formats (and apply the correct rules automatically), but it works for
those types that aren't stored verbatim - for instance it looks like
TimeSpan has a non-trivial implementation.
Marc