You would have recently seen in LinkedIn that Barb asked the following question. “When you add html code into your survey, it displays beautifully but then it displays as code in your tabs. Is there a way in a DMS to globally eliminate any HTML code?” and I pointed him to a post that had been written awhile ago. Also in my comment I mentioned that I had a script that would add a context to an MDD and then strip out the HTML and put just the text in it. This article shows you the code for that script.
The first bit of script that we have , adds the context , and in this case it’s the “CATI” context and then loops all the variables in the MDD,
Dim oMDM Set oMDM = CreateObject("MDM.Document") oMDM.Open("TEST.mdd", , openConstants.oREADWRITE) oMDM.Contexts.Add("CATI") Dim oVar,oElement,sLabel For Each oVar in oMDM.Variables if oVar.IsSystem = False then oMDM.Contexts.Current = "Question" sLabel = oVar.Label oMDM.Contexts.Current = "CATI" oVar.Label = StripHTML ( sLabel ) oMDM.Contexts.Current = "Question" For each oElement in oVar.Elements.Elements oMDM.Contexts.Current = "Question" sLabel = oElement.Label oMDM.Contexts.Current = "CATI" oElement.Label = StripHTML ( sLabel ) Next end if Next oMDM.Save()
you will have noticed that as we loop the variables and find a non system variable. When we have the variable , we set the current context to be the context we want to copy from , take the text and store it in a string variable. Set the current context to be the context we want to update , strip the HTML from string and then set the new value into the new context.
The next code you need in your mrs is the strip html function
Function StripHTML ( sText ) Dim objRegExp, strOutput Set objRegExp = CreateObject("VBScript.RegExp") objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<(.|\n)+?>" strOutput = objRegExp.Replace(sText, "") StripHTML = strOutput Set objRegExp = null End Function
This functions uses regular expressions to strip out the HTML. Basically it says replace anything between and including an < & > with nothing. And there you have a few simple lines that will save you allot of time. Hope it helps !