Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic building of page using XML best practices

Status
Not open for further replies.

rekenaar

Technical User
Feb 16, 2005
38
ZA
Hello.

I am a Java programmer just getting into ASP.NET with C#.
I have started writing an xml schema that will be used to the pages so that it can be created dynamically from the xml.
I just need some input from people with experience in this type of thing to make sure I am on the right path.
Am I correct in using XPathDocument to load the XML document? I need fast, read-only, random access and my research on the net has shown this to be the best option.
My big question is: Where should I load this XML document?
Should I have a class that loads it at application_start (in globals) into Application variables. And then use xpath queries to access the data when needed?
Has anyone had any experience in doing something similiar? What worked best for you? (Best performance, best practice etc.)
Any input would be appreciated.

Thank you.
 
I have an application I just added an XML configuration file to recently. I was in a rush, so rather than going for most efficient I went for XMLSerialization. Basically I have a classes that mirror the outline of my XML file. On App Start I load and deserialize my XML document. I dump a file monitor on it so that when it is modified I can grab it and deserialize the new copy also.
Like I said, it's quick and not exactly efficient, but right now it works and it's really neat to play with.

I have used other methods in the past (I'm vaguelly recalling something like javax.crimson), but take my opinion with a grain of salt, I haven't spent enough time with C# to consider myself an expert.

XMLSerialization uses reflection and can be a pain to add to after the fact. I personally can't stand the XML file + XML Schema -> Magic .Net Stuff -> Datatable approach. Using a reader and XPath statements, in any language, gets a little annoying because I tend to type check everything before casting, plus add a try catch around it. So to get one value you end up with a 4-5 line statement. On the other hand it seemed the fastest and was easier to add to then the Serialization method.

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top