Retirement tax questions

Thanks.  I appreciate the answer.  In your example, if the 10k 529 withdrawal was 6k principal and 4k earnings, could I not cover the 18k expenses as: 10k ira withdrawal, 4k 529 earnings, and finally 4k of the 6k in principal?  In this way, i would owe no taxes.  Reminder - the 529 withdrawal was paid directly to the school.  Also - our income is too high to qualify for the education credits although we have filed for them in past years.