News flash: 2008 has been a rough year for the stock market. The S&P 500 has fallen 14% year to date. With the mortgage crisis at the root of the meltdown, banks and homebuilders have been among the hardest-hit. Megabank Citigroup (NYSE:C), for instance, is down 34% on the year, and homebuilder Lennar (NYSE:LEN) has shed 19%.

You might have presumed that with record high gasoline prices, energy companies would have been tremendous winners this year -- but they're not. Integrated oil giant ExxonMobil (NYSE:XOM) is down some 18%, and refiner Valero (NYSE:VLO) has lost more than half its market cap this year.

Is nothing sacred?
It would be instructive, then, to look at and learn from the small handful of companies whose shares have actually risen, in spite of the general market morass. They include:

Company

Industry

Price-to-Earnings Ratio on 12/31/2007

Price Change

Wal-Mart (NYSE:WMT)

Super Centers

15.3

32.9%

General Mills (NYSE:GIS)

Packaged Foods

17.8

20.7%

Baxter International (NYSE:BAX)

Health-Care Equipment

22.9

17.9%

Unfortunately, we can't go back in time and buy these companies before their ascent. But if we figure out why they've done so well, we might be able to position ourselves to better ride out this market downturn. While these three firms may seem to have almost nothing in common, they do share some key traits. At the beginning of the year, they were all:

  • In critical industries that people won't do without
  • Reasonably valued
  • In control of their ability to price their products

That powerful combination can weather even a nasty economic storm like this one.

Milk and cereal
Just think of how pricey Cheerios would have to get before you'd say something like this to your children: "Sorry kids. No breakfast this week. We can't afford the cereal." Even if you tried to save a few cents by switching to pancakes … General Mills makes Bisquick, too.

For many Americans trying to stretch their dollars, shopping at low-price leader Wal-Mart is almost a no-brainer. Not only can you usually get things more cheaply there, but its superstore structure lets you pick up all sorts of those essentials from the same store -- cutting back your gas usage.

People continue to spend money on health even when the economy is faltering. If you need life-saving care, you get it. Devices to treat hemophilia, cancer, and kidney disease are Baxter's specialty, and nobody can choose when those illnesses strike them.

Defense wins championships
No less an investing superstar than Warren Buffett has said that Rule No. 1 for successful investing is "Never lose money." It's so important, in fact, that his Rule No. 2 is "Never forget rule No. 1."

As an investor looking to learn from this year's meltdown, there's no better lesson than the benefits of buying truly critical companies at reasonable prices. It's how you protect your portfolio and best situate yourself to follow Buffett's rules.

At Motley Fool Inside Value, we take that lesson to heart. In fact, Wal-Mart has been a recommendation of ours since April 2006.

No, we didn't predict when the meltdown would happen or what specific form it would take, but by picking Wal-Mart when it was demonstrably undervalued, we prepared ourselves -- and our members -- to ride through it that much more successfully.

If you'd like to see what stocks Inside Value is recommending today, click here for a 30-day free trial. Our best buys now list contains companies that should help you survive this market -- and profit when it turns around.

At the time of publication, Fool contributor Chuck Saletta owned class B shares of Lennar. Wal-Mart is an Inside Value selection. The Fool's disclosure policy is particularly fond of Honey Nut Cheerios.