I am using a Cobra board.
I have stored a XML file(size of 10kb) on my SD-Card. I have used that example
( http://wiki.tinyclr.com/index.php?title=XML ).
I am wondering how long it takes( about 1,5 sec) just to initialize/ mount my SD-Card.
Even the parse of XML take about 2,5 second.
Is there any other way to parse a XML file in a quicker way?
Are you parsing it off the SD card or reading in memory and then parsing in memory?
Here is an extraction of my code.
I am adding the XML file into an array and then store it in a memorystream and parse it to the XMLReader.
_storage = new PersistentStorage( "SD" );
_storage.MountFileSystem();
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
filestream = new FileStream( rootDirectory + @ "\test.xml",
FileMode.Open, FileAccess.Read );
xmlArray = new Byte[filestream.Length];
filestream.Read( xmlArray, 0, (int)filestream.Length );
XmlReaderSettings ss = new XmlReaderSettings();
ss.IgnoreWhitespace = true;
ss.IgnoreComments = false;
filestream.Read( xmlBytes, 0, (int)filelength );
filestream.Close();
MemoryStream xmlStream = new MemoryStream( xmlArray );
XmlReader xmlr = XmlReader.Create( filestream);
[/Code]
I am not sure exactly. I did XML parsing before and wasn’t seconds. Maybe the files were smaller than yours.
Here is mine:
FileStream fs = new FileStream("\\SD\\yourfile.xml",FileMode.Open,FileAccess.Read,FileShare.None);
XmlReaderSettings ss = new XmlReaderSettings();
ss.IgnoreComments = false;
ss.IgnoreWhitespace = true;
XmlReader xmlr = XmlReader.Create(fs,ss);
then you just have to parse as described in the tutorial (xmlr.EOF, xmlr.Read, node type …
I don’t know why do you need xmlarray and why you start reading file… So I don’t have any clue if my code will be faster than yours but for sure, it is smaller…
So I adjusted my code with the purpose from leforban.
It got a bit quicker, but it still does not reach the desired speed. Is it normal that the mounting of the SD-Card takes about 1,5 sec? The SD-Card has a size of 2GB and is formated as FAT32. Is another file type recommended?
How much faster you need it to be? Maybe faster device is the only option. ChipworkX and Hydra give you 5 to 6 times the speed.