Skip to content

Instantly share code, notes, and snippets.

@jz5

jz5/Module.vb

Created Jun 28, 2015
Embed
What would you like to do?
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