Finding tags in XML file not used in other files

  • Thread starter Thread starter Elhurzen
  • Start date Start date
E

Elhurzen

X-No-Archive: yes
I have an XML file with hundreds of <resource> elements:

<resource name="val">
...
</resource>

There are now tens of files (written in a mix of C, C++ and C#!) in
another directory. I want to find all resources (by "name") in the XML
file that are not referenced anywhere in the files in the other
directory.

For example, if there's a tag <resource
name="RandomResource">...</resource> in the XML file, and the string
"RandomResource" (with or without quotes, as a whole word or not) is
not mentioned anywhere in the *.c and *.cpp and *.cs files in the other
directory, I want to know.

How exactly can I accomplish this? Is it even easy to do this in C#
(1.1 or 2.0)? I'm a newbie when it comes to files and XML in C#, so
specific pointers will be appreciated. If C# is not good for this, I
would at least like to know how I can tackle the problem.
 
Hi,

you can read the xml using something like XmlTextReader and check the file
using Directory.GetFiles

No idea if there is a better solution, but that works .


cheers,
 
As an outline, I would first "scan" all XML files building a table of
resource names (could be multithreaded), then grep the source files in some
way.
 
Back
Top