Groups | Blog | Home
all groups > dotnet xml > march 2007 >

dotnet xml : XML file loaded and stored as cached dataset?


doug
3/15/2007 3:59:08 PM
Have loaded balanced web servers that we do not allow to connect to our
database. Content is created and pushed to these sites. I want to add a web
service that may get multiple requests a second depending on peak access. I
have built an XML file from SQL DB and pushed this file to web server. I
want to load XML file at application startup and leave it cached if possible
(it will vary in size from 1-2MB) and treat it like an SQL table (rows &
columns) that I can filter on and send XML subset back to caller. Maybe I
should keep XML document loaded as XML Doc and pull my nodes/data from there
and send it out.

I'm concerned also about limitations caused by concurrent access to data.

regards,

v-wywang NO[at]SPAM online.microsoft.com (
3/16/2007 12:54:20 PM
Hi Doug,

Have you considered loading data from XML file as Dataset and caching it?
About how to load dataset from xml, you can reference.
http://msdn2.microsoft.com/en-us/library/fx29c3yd.aspx
[Loading a DataSet from XML]

If you use XML document rather than Dataset, I think you will lose many
useful features such as relationships, primary key, foreign key, and the
data type...
Additionally, It will become very difficult for you to get related rows.
You will lose the ability to know what type for each column. ..

Have a great weekend,
Sincerely,
Wen Yuan
doug
3/16/2007 2:11:00 PM
I'll give it a try. Thanks. May take a few days to respond back.

doug

[quoted text, click to view]
doug
3/20/2007 3:56:16 PM
I have asked our web support group to verify thier standards are current.
Current standards state "absolutely NO View State" and Datasets should NOT be
used for web service or any high performance tasks. Is their another option?
Recall, no direct access to RDBMS, just a pre-built and staged XML file to
filter on to send XML packet response.

doug

[quoted text, click to view]
v-wywang NO[at]SPAM online.microsoft.com (
3/22/2007 4:47:17 AM
Hi Doug,
Thanks for your reply.

As far as I know, we have four choices for your scenario.
(DataSet/DataTable, XMLDocument/ XmlReader, XMLDataDocument, XML
Serialization). DataSet is the way to represent data as relational view
and XMLDocument is another way to represent data as hieratical view.
Additionally, the XmlDataDocument class is derived from the XmlDocument
class, providing a hierarchical view of data as well as a relational view
by binding it to a DataSet. The primary purpose of XML serialization in the
..NET Framework is to enable the conversion of XML documents and streams to
common language runtime objects and vice versa.

In general, I would like to suggest you consider using DataSet/DataTable,
but it seems like your current standards restrict you from
DataSet/DataTable. However, now, the choices for us are
XMLDocument/XMLReader and XML serialization, as you said in initial post.
XMLTextReader is the fastest way to get the data via the pull-model XML
parsers.

I noticed there is a question very closed to your issue in WebQA article. I
highly recommend you may reference it.
http://msdn.microsoft.com/msdnmag/issues/02/12/webQA/
Q I'm looking for tips on getting the best performance from my use of the
System.Xml classes in an ASP.NET Web Service. Would I see a benefit from
long-term caching and reuse of System.Xml objects, like XmlDocument?

Additionally, you may meet an issue when using XmlDocument elements passed
to or returned from WebMethods. The following KB will tell the story for
you.
http://support.microsoft.com/kb/330600

Hope this helps. If you still have anything unclear, please feel free to
update here.
Have a great day,
Sincerely,
Wen Yuan
doug
3/28/2007 6:36:01 AM
Wen Yuan,

Okay, got web service loading up XML file into dataset and I can send
dataset back to new XML document and return that as my result.

I have 5 layers on my XML. Users will want to select specific level 2 and
level 3 nodes plus child nodes 4 and 5, and parent 1. They will be passing
in an XML packet that has filter criteria level2='6' and level3='B'. I
assume I will load this into dataset also and use the two datasets maybe as a
join where node level values are equal?

How do I select rows from the dataset?

So far, not much code. Very clean. I am enjoying the project.

doug


[quoted text, click to view]
v-wywang NO[at]SPAM online.microsoft.com
3/29/2007 12:00:00 AM
Hi Doug,
Thanks for your reply.

Dataset will load the xml file into datatables.
For each table, you can select the rows by the method DataTable.Select()
http://msdn2.microsoft.com/en-us/library/det4aw50.aspx
[DataTable.Select Method (String) ]

Additionally, get the rows( from Child/Parent table) related to your
selected rows.
DataRow.GetChildRows
http://msdn2.microsoft.com/en-US/library/hbt8xha8.aspx

DataRow.GetParentRows
http://msdn2.microsoft.com/en-us/library/7bssayw4.aspx

Hope this helps, please feel free to let me know if you still have anything
unclear. I'm glad to assist you.
Have a great day,
Sincerely,
Wen Yuan
doug
3/29/2007 5:16:02 AM
This is kind of what I imagined, but hoped it would be simplier. Will give
it a try.

Thanks.

[quoted text, click to view]
AddThis Social Bookmark Button