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
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