Help needed in writing awk script for xml source

Hi, i am not able to get an approach for converting xml file to flat file using awk programming. Can anyone help me out.

The input xml is like this:

<outer>
<field1>one</field1>
<field2>two</field2>
<field3>three<Error Code=777 Description=12345/></field3>
<field4>four</field4>
</outer>

Expected output is like this:

field1 field2 field3 field4 Code Description
one two three four 777 12345

The field1, field2, ... should not be hardcoded.

Thanks in advance,
Naren

Not sure if this is a similar post to this ?

http://www.unix.com/unix-for-dummies-questions-and-answers/43190-xml-to-pipe-delimited-flat-file.html

Yes, both the posts looks very similar and they come from the same IP. I have a feeling it is a homework question.

Closing this thread and the other one.