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 = documentXMLStri ng.DocumentElem ent;
XmlNodeList records = root.ChildNodes ;
XmlAttributeCol lection attributes;
for (int i = 0; i < records.Count; i++)
{
attributes = records.Item(i) .Attributes;
concept_id=int. Parse(attribute s.GetNamedItem( "id").InnerText );
rank=double.Par se(attributes.G etNamedItem("ra nk").InnerText) ;
concepts_.Add(c oncept_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.Par se(attributes.G etNamedItem("ra nk").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 = documentXMLStri ng.DocumentElem ent;
XmlNodeList records = root.ChildNodes ;
XmlAttributeCol lection attributes;
for (int i = 0; i < records.Count; i++)
{
attributes = records.Item(i) .Attributes;
concept_id=int. Parse(attribute s.GetNamedItem( "id").InnerText );
rank=double.Par se(attributes.G etNamedItem("ra nk").InnerText) ;
concepts_.Add(c oncept_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.Par se(attributes.G etNamedItem("ra nk").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
Comment