RegEx to remove invalid XML characters

I am storing data collected on a website as xml in ms sql 2005.

some characters are not allowed and I recieve "XML parsing: line 3, character 27, illegal xml character"
I believe what happens is people type up information in MS word or a similar program that uses extended characters such as curly quotes.  When I find an new illegal character I try and replace it.  But doing each illegal character seems clunkly.  I'm assuming there has to be a RegEx solution here.

Can anyone give me a vb.net example of a RegEx solution that will strip out all non legal XML characters as defined by MS SQL 2005.

Thanks
dbashley1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lakram5455Commented:
Here is the exact link, which talks about how to parse & remove invalid characters                                             in XML File using C#. May be you can convert this into VB.NET using some convert tool.

http://forums.microsoft.com/msdn/showpost.aspx?postid=1824669&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=0
0
dbashley1Author Commented:
lakram,

parsing an error message isn't really the solution I'm looking for.  The error message could change with the next version of .net or other senarios that I'd be trying to anticipate.

I'd really like a RegEx solution if that is possible.

0
livepersonincCommented:
Balaji Ramesh has published a code that does exactly this. You can get the regular expression that he used:
http://balajiramesh.wordpress.com/2008/05/30/strip-illegal-xml-characters-based-on-w3c-standard/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.