I've done this a few times and a few things became apparent rather quickly.
D&D is not a great combat sim, and that is more obvious when you expand the scope of the conflict. This can be avoided by steering the PCs into a more isolated portion of the battle. Remember in Prince of Persia (the movie) when old boy infiltrates the city through a minor gate with a small band of irregular troops? Perfect. How about sapping, or counter-sapping, that breaks into tunnel fighting? Taking out a band of insert dangerous elven ally here that are crushing your troops. Sneaking over/under/through the wall to sabotage catapults or assassinate leadership. Defending your leaders from an enemy strike team. Smashing through enemy defensive positions inside the city once the walls are breached works well also, and can be a great opportunity to fight NPC sub-commanders trying to rally the troops.
If you DO want that big battle feel then you need to be thoughtful in planning encounters. Random arrow fire, either a volley every few rounds or a constant 1d4 per round, can add realism. Fights should have reinforcements every round or two (for either/both sides,) unless it becomes a duel between elites. Flying creatures can fall/dive out of the sky. Siege weapons and spells should change the battlefield periodically. I was a big fan of mapping groups of combat around the edges of a small encounter area and anyone that got close to those fights might prompt a reaction from friend or foe there. Sometimes, let the PCs carve a path of destruction through groups of mooks, but when this happens the enemy forces should react by dispatching elites (or wizards) to counter the PCs and rally the survivors.
As for the outcome of the battle, you can predetermine the outcome logically or randomly if you want, but I always like to base the battle outcome on the players' actions. If they succeed, then so does their army. There is another process from a 3e/3.5 book called Heroes of Battle that suggests assigning points to different objectives and determining the outcome based on how many points the PCs can obtain. Might be worth looking up.
Edit: vs elves, be ready for the PCs to suggest burning everything. The forest, the city, small children, your DM screen... have an answer for why fire isn't the answer. Could be as simple as the army wanting booty and fires getting out of control, but you need to be ready for that.
I'd love to offer more specifics, but you'd need to detail the city, inhabitants, surrounding area, and possibly allies/enemies/political climate, etc.