To restrict parts of a mesh from rendering
You can make use of the Mask Modifier for this.
The Mask modifier allows certain parts of an object's mesh to be hidden from view (masked off), in effect making the parts of the mesh that are masked act as if they were no longer there.

This is probably the best way to go about this, any shader trick that selectively hides a mesh could cause problems depending on usage as transparent geometry is still outlined with Freestyle Line renderer for one. The mask modifier gets rid of it completely visually, but preserves physics etc.
To restrict an object from rendering
You can restrict entire objects from rendering by pressing the camera icon in the Outliner or by selecting the objects that you do want to render and using CtrlW > Restrict Render Unselected to restrict any unselected objects from rendering.
Alternatively you can exclude whole layers of objects via the render layer settings.