I need to be able to search several thousand XHTML and XML files and see a list of files that do not contain the following string on the first line:

<?xml version="1.0" encoding="utf-8"?>

How would I go about doing this? I thought I could do this in Notepad++ using the Search in Files function, but I do not see any way to look for a string that is not found and/or properly formatted and have it output a list of files.

  • 1
    What operating system are you using any way? – Angel Brighteyes Oct 11 '12 at 19:16

Use Agent Ransack and set it to only search through .xml file types. If you know RegEx use that, I am at work or I would help with that. I believe Agent Ransack comes with the ability to just use a negative search but I'll have to check.

Agent Ransack has a "Specifies Not Expression" which will work for what you want, but you will need a regular expression match string in order to pull it off. If you are a developer it is a good skill to at least be pseudo familiar with enough to do some basic searches or text matching with.

[Edit] Agent Ransack does not have a "Not Expression" search ability. The RegEx was pretty simple though

(<\?xml version="1.0" encoding="utf-8"\?>)

I'll keep looking for a tool/utility app.


I know this is an old question, but I came here looking for the same information and thought I'd share a simpler solution using Agent Ransack, which does in fact allow you to specify a NOT condition. For the above question, using the following as the text to search for works perfectly, and the only necessary modification to the string in question is escaping the double quotes:

NOT "<?xml version=\"1.0\" encoding=\"utf-8\"?>"

Hope this helps someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.