I am trying to parse an XML file and extract data from elements. The problem is that every time I use ReadElementContentAsX, the reader skips the next element. I don't know why is that. What am I missing?
while (reader.Read() && fileValid)
{
if (reader.IsStartElement())
{
Console.WriteLine(reader.Name);
switch (reader.Name)
{
case "ID": if (reader.ReadElementContentAsString() != ID) { fileValid = false; } break;
case "Size": if (reader.ReadElementContentAsInt() != EEPROM_SIZE)
{
fileValid = false;
}
break;
case "Data": reader.MoveToContent(); if (reader.ReadElementContentAsBase64(eeprom_primary, 0, EEPROM_SIZE) != EEPROM_SIZE) { fileValid = false; }
else
{
}; break;
default:
break;
}
}
}
The XML structure is as follows: -ParrentNode --ID:String --Date:TimeDate --SoftwareVersionMajor:int --SoftwareVersionMinor:int --Size: int --Data: encodedBase64
So in my case i read element content for element ID, Size. It will skip element Date and Data. I checked if i remove the readElementContentAs it will not skip the next node
No comments:
Post a Comment