none
Run .Net Script Error while trying to remove html tags from a string input

    Question

  • I am pulling a Text String from a SharePoint list, and it contains html tags like <div> <br /> etc. I want to remove them so that the text looks a little better when added to a Service Request, but the .net script activity is throiwn an error. The script runs fine in PowerShell.

    $Input={Request Description from "Get List Items"}
    $Regex="</?[^>]*>" #Should remove all <> Tags and anything inside them.
    $nbsp="&nbsp;"
    $InitialOutput=$Input -replace $nbsp
    $Output=$Initialoutput -replace $Regex

    The error I get is: Ampersand not allowed. The & operator is reserved for future use; use "&" to pass ampersand as a string.

    Second Error: The '<' operator is reserved for future use.

    I tried escaping the & Ampersand within the variable declaration like "`&nbsp;" but it still threw an error.

    Anyone able to help me with this?

    Goal:

    Input String: <html>I would like access to <div> the application I need to use called &nbsp;<br>Application</br></div></html>

    Desired result: I would like access to the application I need to use called Application

    Thanks for any assistance!

    Tuesday, March 14, 2017 7:51 PM

Answers

  • I'm sorry, it hit me right after I posted this.

    I added "" around the published data link that I used as my input variable and it worked perfectly.

    Sorry for the needless post.

    $Input="{Request Description from "Get List Items"}"

    Tuesday, March 14, 2017 7:55 PM

All replies