If all your files have a namespace declaration, With GNU/FreeBSD/OSX grep or any implementation that has the
-m option, you can look for the namespace declaration and quit as soon as it's found, then pipe the result into a second grep to get the namespace that you're interested in.
grep -m xmlns: *.xml |grep 'xmlns:crm="http://www.cidoc-crm.org/cidoc-crm#"'
If some files lack a recognizable namespace declaration or some other pattern that says “quit”, use sed or awk instead to specify a quitting condition based on the line number. With sed, there's no way to count lines per file, so you'll need to invoke sed on each file:
for x in *.xml; do
if [ -n "$(sed -n -e 's/.*xmlns:crm="http:\/\/www.cidoc-crm.org\/cidoc-crm#".*/1/' -e '/xmlns:/q' -e '5q')" ]; then
printf '%s\n' "$x"
See Stéphane Chazelas's answer for an awk solution.
Any method based on text processing tools is inherently fragile. For example, it would pick up a namespace declaration that's commented out. Unless you're going to review the results manually or you know that all your files have a “tame” structure (no comments, no payload text that looks like what you're searching, etc.), you should use a proper XML parser instead — but it will be slower.