I am trying to achieve the below 2 things, when loading and parsing XML file recursively.
1. Avoid duplicates
2. Avoid loops.
My XML file contains other XML file names as well. I have to load the main file first, then parse file names under tag. Once parsing completed, i have to load and parse these files one by one. While i doing these, i have to show message for duplicates or loops recursively. Please suggest me the algorithm/ links to solve this issue.
Keep a list of all of the “things” (XML file names in your case) that you have processed. Then, before you process each item, check to see if it is already in the list and warn/error accordingly.
The best way to track this–a linked list, array, dictionary, hash set, etc.–list will depend on the programming/scripting language you are using and the number of entries you expect the “seen items” list to contain.