XmlTextReader or XmlDocument or SQLCE

S

Safae

Hi.


Im using DataSet.readXml/WriteXml for read/write data but is too slow
(the size of my XML file is between 200,500ko)
I want to use XMLTextWriter & Reader but i don't know if i can
manipulate Data easily(read element,update element...)
in My application I make a several calls to the XML file (update, read,
insert elements) and I must save changes in XML file after each call.in
this case what is the better and faster way to read/write data :
XmlTexReader or XmlDocument or i must work with the SQL CE

sorry for my bad English and Thank you for all your help

Regards
 
S

Simon Hart

200-500 kilobytes? if so then using any XML class in CF will be dog slow
when XmlTextReader.

SQL CE will improve performance no-end. I find just reading an XML config
file in my app very slow and it is only around 300 bytes.

Cheers
Simon.
 
S

Safae

Thanks for your help,

but if I reduce the size of my XML file to 150 ko,200ko, I will have
the same Problem? can I still work with XML file because SQl CE is not
appropriate to me ?

by using dataset functions the real problem is not in readxml function
but in WriteXML because I must after each change of data call this
function. that's mean if I update one record of dataset the function
WriteXMl rewrite all the file. there is no possibility to save changes
in XML file by another way for example by XMLTextWriter?instead of
Dataset.writeXml?

Regards
 
I

Ilya Tumanov [MS]

Actually, this "dog slow" idea is mostly from combination of unrealistic
expectations (e.g. my desktop with 3+GHz superscalar fully featured CPU with
2GB or extremely fast RAM does that in 1 seconds, why it takes 2 minutes on
puny 200 MHz RISC processor with slow 16 bit 32 MB RAM?), older hardware
(e.g. 100MHz PPC 2000), older versions of NETCF (V1 RTM instead of SP2+ or
V2) and improper ways of working with XML (e.g. using inference to load XML
into DataSet or using DOM to get a single value from a big file).


It is very possible to achieve adequate performance on relatively modern
hardware running NETCF V1 SP3 or V2.



With XmlTextReader it should take about a second to read 200K document node
by node.

DataSet.ReadXml() would load it in about 2-3 seconds assuming schema is
used.



This data is for NETCF V2 running in PXA 255@400 MHz on PPC 2003. It's about
twice as long for NETCF V1 SP3.



So, it should be OK to use DataSet.ReadXml() with 200-500K XML.



Just make sure:

- You're using schema (typed DataSet, created programmatically, loaded from
separate file or embedded into the XML).

- Avoid using DateTime fields as they are very slow to parse.

- Use related tables instead of nested tables.


As to saving XML file after each change, simply don't do that. Imagine Word
would save each time you type one character, now that would be terrible.

DataSet is especially designed so you don't have to do that. It cashes data
in memory so you can access and change it as needed and persist it from time
to time.

Save it only on user request, on timer or if your application closes.



And no, there's no way to update part of XML with any class, it can only be
rewritten as a whole.

This is indeed a big disadvantage of XML compared to even comma separated
file; you can at least add records to it which is not possible with XML.


Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
S

Simon Hart

I wouldn't really call it "unrealistic expectations", I would call it
experience, and testing. I would love to see a 1 second response time
reading a single node from a 200k XML file on any version of CF running on
any processor.

It's really a no brainer, why give yourself so much work when a tool such as
SQL CE does it (and does it a lot better - with more options) without having
to do hardly any work.
 
S

Safae

Thanks for your help.

I'm trying to test both of solutions :Dataset and SQL ce.
about Dataset: I have installed SP2 and load a schema from seperate
file xsd and Im not using DateTimeFields, so Dataset.readXML takes 7s
instead of 28s for reading xml file with 200 Ko. but I dont understand
how can I Use related tables instead of nested tables.
I have one table who has a child table. Should I add PrimaryKey and
foreing Key for those tables in the xsd file ? I have tried to do this
but it generate an exception.
I have already read an utility who reformat The Xml file buy modifing
DataColumn.ColumnMapping to MappingType.Attribute.
what should I do for using related table?

Best Regards
 
I

Ilya Tumanov [MS]

You should consider having primary key/foreign keys in any case; it's a must
for any DB.



As to relations, you can change relation type from nested to related in
schema editor.

Also, I've posted source code for utility which does that a while ago.
Should be easy to find using link below.


Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top