Can you live in the world but not live of the world?

You can certainly try, but it's not easy. To live in the world but not be of the world means to be physically present in the world (a real, live human being, in other words) but not get caught up in human emotions like greed or jealousy or anger (to remain above all the negativity and focus entirely on spiritual pursuits like following the teachings of your religion). Many spiritual leaders like Jesus or Moses or Buddha were believed by their followers to have lived here on earth, yet they rarely (if at all) got caught up in human faults and failings. They were in the world, but they were not of the world-- they were special and unique examples of spirituality and selflessness.