Geeks With Blogs
Andy Morrison's BizTalk Blog Help, I've fallen and I can't BizTalk!

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

I've been working with a third-party database adapter that returns encoded Xml in some cases.  BizTalk handles the decoding just fine but when I have problems with the adapter it can be problematic to examine the encoded documents.  After a few days of dealing with this I put together a couple of VS.NET macros for encoding/decoding Xml which I'm sure people can find other uses for.

 

Here's how you can create these macros:

 

  1. Open VS.NET.
  1. View the Macro Explorer.
  1. Copy and paste the code snips, below, into appropriately named macro module (I created a new Macro Module and named it XmlHelpers.)
  1. Make sure you add a reference to System.Web in the macro editor for the macro module you just pasted the code snips into.
  1. Add an Imports statement for System.Web
  1. Save the macro.
  1. Select an Xml fragment in the editor that you would like to encode or decode.
  1. Double-click the XmlEncode or XmlDecode macro in the Macro Explorer.
  1. Note that it is actually using the System.Web.HttpUtility.HtmlEncode/HtmlDecode functions.

 

Here are the snips:

 

Sub XmlDecode()

Dim theTextSelection As TextSelection = DTE.ActiveDocument.Selection

Dim actualText As String = theTextSelection.Text

 

theTextSelection.Delete()

theTextSelection.Insert(HttpUtility.HtmlDecode(actualText))

End Sub

Sub XmlEncode()

Dim theTextSelection As TextSelection = DTE.ActiveDocument.Selection

Dim actualText As String = theTextSelection.Text

 

theTextSelection.Delete()

theTextSelection.Insert(HttpUtility.HtmlEncode(actualText))

End Sub

 

Posted on Wednesday, December 6, 2006 7:19 AM BizTalk | Back to top

Copyright © Andy Morrison | Powered by: GeeksWithBlogs.net