I've had a few requests to find the pages where class "X" is being used and tried using the search function included in Drupal.
The search seems to only go through the text of a node, and not the HTML of the body field.
Is it possible to do this? Is there a module that has this kind of functionality? Or do I pretty much need to do a db_query on the body field of all nodes to find it?
A module or baked-in ability to find HTML would really save me some time if you're aware of any. D6 and D7 answers are appreciated.
Thanks!
You can't find what you are looking for using standard search because Drupal performs searching against indexed content which is sanitized from most of HTML stuff. You can see it in action here:
https://api.drupal.org/api/drupal/modules%21search%21search.module/function/search_index/6:
// Strip off all ignored tags to speed up processing, but insert space
// before/after them to keep word boundaries.
$text = str_replace(array('<', '>'), array(' <', '> '), $text);
$text = strip_tags($text, '<' . implode('><', array_keys($tags)) . '>');
This applies to both Drupal 6 and 7.
You can read more about indexing here: http://www.acquia.com/blog/drupal-search-how-indexing-works
As for the second part of your question - I could not find any custom module that searches for HTML, so I think you best option is to write your own module and query all nodes' bodies.