Skip to content

Instantly share code, notes, and snippets.

@jz5
Created June 28, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jz5/26ac310543c1314e60a1 to your computer and use it in GitHub Desktop.
Save jz5/26ac310543c1314e60a1 to your computer and use it in GitHub Desktop.
Sub Main()
Dim url = "http://example.jp/xml"
Dim client = New WebClient With {.Encoding = Text.Encoding.UTF8}
Dim xml = client.DownloadString(url)
Dim d = XDocument.Parse(Sanitize(xml))
End Sub
Private Function Sanitize(xml As String) As String
Dim sb = New Text.StringBuilder
For Each c In xml
Dim code = AscW(c)
If code = &H9 OrElse
code = &HA OrElse
code = &HD OrElse
(&H20 <= code AndAlso code <= &HD7FF) OrElse
(&HE000 <= code AndAlso code <= &HFFFD) OrElse
(&H10000 <= code AndAlso code <= &H10FFFF) Then
sb.Append(c)
End If
Next
Return sb.ToString
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment