Strip HTML formatting and special characters from CCHTMLString

Hi all,

I’m new here so my apologies if I’ve put this in the wrong section or created a duplicate post.

I’m working within AX 2009 Dynamics and am programatically building XML which is being submitted to various partners. One of the partners is unable to accept HTML in one of the fields we are sending. The field is of data type CCHTMLString (which appears to be based on a Memo field) and I wondered if there are any built in X++ routines or routines that you may have previously created which are able to strip out the HTML within the field data along with any non-alphanumeric characters.

I can’t simply strip out non-alphanumerics as this would leave the resultant string peppered with bare HTML tags so I guess I need to remove these first.

Any assistance would be greatly appreciated.

Thanks,

Steve

You’re not limited to X++ - thanks to .NET Interop, you can use the same ways as .NET developers, e.g. regular expressions. Look at C# Remove HTML Tags, for example.

That’s great, thanks for the pointer!

I managed to find a REGEX which strips all HTML tags and for anyone that may be interested, did this;

new InteropPermission(InteropKind::ClrInterop).assert();
advertsend = System.Text.RegularExpressions.Regex::Replace(advertsend,’\<[^\>]*\>’,’’);

Some useful further reading (other than the very useful link above)

http://www.fourone.se/blog/2009/10/02/using-regular-expressions-in-dynamics-ax/