Monday, August 23, 2004

Reading Text file with XML DOM object

Hi,
XML DOM has no limitations on the kind of file it can open, what is important is that the content be XML. In your case, for this document to be a valid XML Document, the root node is missing. So, you would have a two step process for processing this doc as XML DOM.
1. Using XML Dom, create the root node and read the TXT file into a filestream
2. Concat the TXT file to the root node created above.

Now coming to the caveats of DOM.
Remember, DOM creates a tree in mem. This tree is so huge that its nearly 10 times the size of the original doc, once in memory.
Secondly, DOM is slower any day to actual raw file processing i.e. using streams. FSO is a different story. For that the VBScript engine has to be loaded, and then the file loaded (Unless of course you are referring to a VBScript here :) )

My suggestion would be, load the file into the FSO as you are doing now, and use the RegularExpression object (available in both, .NET as well as VBScript 5.0 onwards) to select the text between the and tags. Don't go for DOM unless you are looking at some requirement in the future which might need this doc available for XML processing.

With Best Regards,
Mitesh V. Mehta
Email : miteshvmehta@gmail.com
http://cc.1asphost.com/miteshvmehta/

No comments: