| || |
Improving performance of my vb script
Hi I developed a vbs file to compare xml files in one folder(Source folder) with the xml files in the another folder(Target folder) .I know there are some tool available in the net to do that .I developed because the document in the xml won't be in the specific orders >let say if there is an employee information in the XML file 1 the same information will be available in the XMl file 3 in the target folder.So i written my vbs to search the employee information and then compare with the XML
Here is my pseudo logic
Source folder Path
Target folder Path
Loop starts source folder
2.Pick the xml one from the source folder path
3.get the first employee information from the XML XMl dom A
Loop starts target folder
2.Load the xml
3.Find the employee information using Xpath
4Save the employee information XML dom B
Go to FuncCompare()
Will take each and every element with their parent information and value and stores it in the Dict A
Will take each and every element with their parent information and value and stores it in the Dict B
Compare Dict()-This will write in a excel
how to improve the logic
I think it'll depend on the level of accuracy you need. If you want to do something that's equivalent to a quick and dirty checksum, such as using regular expressions or string search to search for the presence of the same token, you may be able to verify to some level they have the same content, but not if the file is correct or not.
For example... Say I have the following procedure.
1. Tokenize XML file A, using regex "<[^>]*>". This will give you a bunch of tags, like ["<rss>", "<article>", "<title>"...]
2. Then for each token, do a search and replace of the 2nd XML file B, and remove the match from the string.
3. At the end of this, you should receive an empty string.
How this could be faster is it avoid loading the parsed XML file into memory (which is memory intensive because you create an object for each node), and you also avoid doing node traversal (which is an expensive tree travesal problem).
however the weakness is it may not verify if the tags are in the right approximate order, or if the XML file actually parses correctly to begin with. But it can quickly verify content is roughly the same.