Last active
August 29, 2015 14:11
-
-
Save IISResetMe/6f4de981c9e179af699a to your computer and use it in GitHub Desktop.
Sanitizes your XML input!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Repair-XmlString | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true,Position=0)] | |
[string]$inXML | |
) | |
# Match all characters that does NOT belong in an XML document | |
$rPattern = "[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000\x10FFFF]" | |
# Replace said characters with [String]::Empty and return | |
return [System.Text.RegularExpressions.Regex]::Replace($inXML,$rPattern,"") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment