I'll second davorg's advice: try to fix the source. If you try to fix it yourself you will have to make assumptions about what you get (starting with "even if tags are mixed there is just one way to make sense of it"), and one day these assumptions will not be true, your XML processing chain will be hosed, usually at the worst possible time... and you'll be in a lot of trouble.
That said... maybe tidy can make sense of it and spit out proper XML, especially if you are working on some kind of HTML-based-not-quite-XML. Look especially at Teaching Tidy about new tags! in the doc
In reply to Re: Fixing ill-formed XML
by mirod
in thread Fixing ill-formed XML
by mush4brains
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |