Drupal - Altering body text of a node before the page is rendered
Try this in mytheme_preprocess_node:
function mytheme_preprocess_node(&$vars) {
// Collect / create / adjust new body content
$new_body = 'xyz';
// Assign to output
$vars['content']['body'][0]['#markup'] = $new_body
}
After looking through the vars array a bit, I'm a little surprised at the amount of redundant data there. There are a few different places where the body text is recorded, usually as an array.
Note that the node body will likely have a 'safe value' and a 'value'. You'll probably want to use safe almost all the time, but it might be good to check on the filter type selected in $vars['body'][0]['format'] to select which of the body values you'll want to output and display.