|
-
Jun 20th, 2006, 07:07 PM
#1
Thread Starter
Hyperactive Member
[2.0] loading config.xml file into XMLDocument object
Task:
load an xml document into XMLDocument object.
XMLDocument xmldoc;
xmldoc.Load(xrdr);
This task can be done one step (as shown above) but the books & experienced programmer at work does that task in 4 different steps: curious to know opinion of other c# programmers.
FileStream input; // maintains connection to a file
StreamReader fileStreamReader; // reads data from a text file
XmlTextReader xrdr;
XmlDocument xmldoc;
//Create a filestream to get the read access to the file
input = new FileStream(StartUpPath, FileMode.Open, FileAccess.Read);
fileStreamReader = new StreamReader(input);
xrdr = new XmlTextReader(fileStreamReader);
-
Jun 20th, 2006, 07:25 PM
#2
Re: [2.0] loading config.xml file into XMLDocument object
You can open an XML file in one line by passing the path of the file to the XmlDocument.Load method. That's very simple code but it doesn't mean that it's the most efficient. It may be that if you were to write a few more lines of code the actual process would execute less MSIL. That would make your application more efficient, but by such a small amount it would be completely insignificant. Unless you know that writing more code will make your app more efficient then write the least code you can to make your purpose clear. Even if you can make your app more efficient, is it worth loading an XML file a few nanoseconds faster and then wait for a couple of seconds while the user gets into gear and does something with the result?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|