The comparison that comes to my mind is the American invasion of Italy, chasing the German army out. My (probably crude TV-influenced American) version of that is that the Italians had had it up to here with the Germans, they welcomes the Americans, you could tell the Germans from the Americans, and the Americans blew up a lot of stuff but gradually chased the Germans out. Then, they left, and Italy returned--after a lot of trouble--to its regularly scheduled government.
The problem in Iraq and Afghanistan is that we're not chasing out an invader, we're taking sides in a bunch of internal disputes none of which have much to do with western democracy. For example, first we kick out Saddam (Sunni) and set up a new government (Shia), then we help the Kurds, which makes the Shias mad, and then give money and guns to the Sunnis to keep them temporarily quiet, and find that in the meantime the Kurds have started fighting with the Turks--our "best" ally in the region--and the Turks have responded with a little mini-invasion of their own, exposing the weakness of our Shia puppet government which is now probably going to collapse. Remind me which side of this are we on again???
It's hopeless. We should take the defense budget and spend it on conservation credits and just cut off the Middle East entirely. It will be quite surprising if Obama takes this approach, though. I expect that he will surround himself with mostly the same advisors that Clinton would, and the overall results will be about the same. Basically, the U.S. is addicted to M.E. oil, period.