When designing forms with InfoPath 2003 or InfoPath 2007 there was always an instance that the form would get corrupted and it could no longer be viewed or published. Still today it's a big mystery for me on why it happens because I've never spent the time to research the problem because I'm usually able to fix it with small amount of extra work and below is how I do it.
Normally I get an error message like

or

when trying to preview or publish a form.
If the error occurs while the designer is still open then I usually close the designer without saving my changes if only minimal work has been done and then reopen it and the problem is gone. If I've worked on the form for a long period of time then I save my changes and close the designer. Then make a backup of the InfoPath form file and change the "xsn" extension to "cab". Once it's changed to a "cab" file I open it and extract the contents into a folder and then open the "xsf" in notepad. You don't have to open the "xsf" file in Notepad but it should be opened in a text editor. If you try to open it by double clicking it then InfoPath tries to open it and the below error message will most likely appear.

Once the "xsf" file is open then search for the corrupted line or lines of code. Once you find all the corrupted code remove it and save the file. For my instance it was the following code that was corrupted.
<xsf:xmlToEdit name="FileAttachment_91" item="/my:AppChangeRequest/my:FormFields/my:Business/my:Attachment/my:FileAttachment" container="/my:AppChangeRequest/my:FormFields/my:Business/my:Attachment/my:Ċ넄ǚ蛤ôƟ眤ô眤ô㹰ċ">
<xsf:editWith caption="FileAttachment" xd:autogeneration="template" component="xCollection">
<xsf:fragmentToInsert>
<xsf:chooseFragment parent=".." innerFragment="my:FileAttachment">
<my:FileAttachment xsi:nil="true"></my:FileAttachment>
</xsf:chooseFragment>
</xsf:fragmentToInsert>
</xsf:editWith>
</xsf:xmlToEdit>
Then open the "xsf" by double clicking it and InfoPath will open the form successfully if no other errors are found. At this point just save the form to recreate the "xsn" file and you are then set to start making new changes. All the files that were extracted from the "cab" file and the "cab" can be safely deleted at this time because the new "xsn" file was created when the form was saved.
If the form was created as a Visual Studio project then all you need to do is close and save the "xsf" file and reopen the file with one of the available text editor choices. These are available when the "xsf" file is right clicked on from Solution Explorer window. Once the corrupted code is removed, save the file. At this point re-open the file to make new changes the normal way.
If the form is saved and closed and then opened later then you might get this error.

If you get this error without the any of the details then finding the error might be a little hard unless the corruption is obvious while the code is reviewed with a text editor. I've ran into this situation a couple of times and I've been lucky enough to find the corrupted code. If you can't find the corrupted code then you will have to revert back to the last published version of the form.
As always if anybody else has any insight I would love to hear about it.
Cheers