G
Guest
Hello,
I´ve a problem with parsing a double value from an xml file.
My code looks like this:
int concept_id;
double rank;
XmlElement root = documentXMLString.DocumentElement;
XmlNodeList records = root.ChildNodes;
XmlAttributeCollection attributes;
for (int i = 0; i < records.Count; i++)
{
attributes = records.Item(i).Attributes;
concept_id=int.Parse(attributes.GetNamedItem("id").InnerText);
rank=double.Parse(attributes.GetNamedItem("rank").InnerText);
concepts_.Add(concept_id, rank);
}
The variable concepts_ is a Hashtable.
A typical XML file looks like this:
<root>
<concept id="20114" rank="1" />
<concept id="13786" rank="0.5" />
</root>
The problem is with parsing the double value:
rank=double.Parse(attributes.GetNamedItem("rank").InnerText);
For example with:
<concept id="13786" rank="0.5" />
the rank is parsed as "5.0" instead of "0.5"
Do you have any idea what happens?
Regards,
Martin
I´ve a problem with parsing a double value from an xml file.
My code looks like this:
int concept_id;
double rank;
XmlElement root = documentXMLString.DocumentElement;
XmlNodeList records = root.ChildNodes;
XmlAttributeCollection attributes;
for (int i = 0; i < records.Count; i++)
{
attributes = records.Item(i).Attributes;
concept_id=int.Parse(attributes.GetNamedItem("id").InnerText);
rank=double.Parse(attributes.GetNamedItem("rank").InnerText);
concepts_.Add(concept_id, rank);
}
The variable concepts_ is a Hashtable.
A typical XML file looks like this:
<root>
<concept id="20114" rank="1" />
<concept id="13786" rank="0.5" />
</root>
The problem is with parsing the double value:
rank=double.Parse(attributes.GetNamedItem("rank").InnerText);
For example with:
<concept id="13786" rank="0.5" />
the rank is parsed as "5.0" instead of "0.5"
Do you have any idea what happens?
Regards,
Martin