This discussion really hinges on the peculiarities of the particular car market you're in. I'm not a Hyundai fanatic, but here's a couple of points:
1) Pretty much everywhere I've looked, the Sonata is compared to the Camry and Accord. Typical dealer ad - "Comparable room and features for thousands le$$ than Camry and Accord"
2) I'd ignore comparing trim level designations - for example, a "base" Sonata comes with power windows/locks/mirrors, cruise, A/C, and front/side airbags. If you're looking at Camrys that level of equipment is standard on an LE (well, the side airbags are a $200 option on an LE) or costs about $1100 as options on a CE. In fact, the option list for a Sonata is rather short, comprised mostly of a moonroof and trim items.
3) Sonatas in my car market (Florida) have large price advantages over competitors. 5-speed Sonatas are regularly available for less than $14,000; comparable Camry CEs and Accord DXs with comparable equipment run at least $2,000 more; for Camry LEs and Accord LXs, the difference is closer to $3,000.
4) For Elantras, the price advantage is comparable. A "base" Elantra GLS comes with power windows/locks/mirrors, A/C, and front/side airbags. Only options are trim accessories, and a cruise control/keyless entry/radio package. Base Elantras are available for less than $11,000. A comparable Civic (LX) is about $3,000 more. Same or more for a Corolla LE optioned out comparably.
5) You're more likely to get a better deal at a Hyundai dealer than a Toyota or Honda dealer. Then again Florida is served by a Toyota distributor that's known for its excessive additional charges and been sued several times.
6) I wouldn't judge Hyundai by their older cars - much like I wouldn't objectively judge a Ford Focus based on what Ford did with the Pinto. Hyundai has definitely improved. In fact, I haven't seen a bad review of the Elantra yet. Even Consumer Reports, who hasn't been particularly keen on Hyundais rated the Elantra pretty highly.
7) As for looks, I personally prefer the Sonata's "different" rounded look from the overly-angular Camry. I think Toyota went too far in trying to differentiate the current generation Camry from the Lexus ES300. I kind of expected it when I saw a previous gen Camry XLE with the two-tone paint package that looked an awful lot like an ES300. Then again, Toyota dealers here charge almost as much for a Camry XLE as an ES300.
8) Putting the XG300 into perspective, it's a slightly bigger, fully-loaded Sonata with a larger engine, and it's street priced as such. The XG300 is to the Sonata what the Avalon is to the Camry. Definitely less expensive than a Camry XLE here.
9) While people will gravitate to Honda and Toyota, it's sometimes unfortunate that they don't shop. That automatic gravitation causes pricing that's sometimes really whacked. For example, I found that loaded Corollas cost almost as much as comparably equipped Camry CEs just because there are lots of people out there that have to have a Corolla and nothing else. Saw several of them at a dealership and boy, did they ever get screwed over.
Is the Hyundai price differential significant? Depends. If it didn't exist, I'd expect Hyundai sales would hover around zero. I personally found Hyundais a little "plastic-ier" than the competition. If I was going to keep the car for 5 years, I'd seriously consider the Hyundai because of the warranty (10/100,000 powertrain, 5/60,000 bumper-to-bumper, 5 yr roadside assistance) and the fact that depreciation would be a little less of an issue. Less than 5 years, and I doubt it because of the depreciation hit. Then again, if you're paying cash and you invest the $2-3,000 saved for five years I'd guess you'd more than have the depreciation covered.