I have this type of XML format:
<?xml version="1.0" encoding="utf-8"?>
<root>
<descriptor>
<feature>5.12</feature>
<feature>0.0002827647</feature>
<feature>0.0147277</feature>
<feature>0.00037847</feature>
</descriptor>
</root>
using the MSDN example I'm trying to read it like this:
Matrix<float> ObjectDescriptors = new Matrix<float>(200, 4);
XmlTextReader reader = new XmlTextReader("descriptors.xml");
int i = -1;
int ii = 0;
while (reader.Read())
{
if (reader.Name == "feature" && ii < 4)
{
String currStr = reader.Value;
ObjectDescriptors[i, ii] = Convert.ToSingle(currStr);
ii++;
if (ii == 4) ii = 0;
}
else if (reader.Name == "descriptor") i++;
}
I get the following error for the line
AgrObjectDescriptors[i, ii] = Convert.ToSingle(currStr);
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: Input string was not in a correct format.
Seems like the node "feature" is being detected (reader = {Element, Name="feature"}) but its content is empty ("")
using System.Xml; is included
Would be nice if anyone tells me why this error occurs! Thank you!