XmlReader无法读取正确的名称

时间:2019-06-07 09:50:10

标签: vb.net

https://github.com/unicode-org/cldr/blob/master/common/supplemental/windowsZones.xml试图从此链接mapZone读取数据,但代码未读取。自3年以来,它一直运行良好。

它正在突然读取一些空白,试图包含一行忽略空白的行,现在它的读取名称为“ head”,“ meta”,“ link”,而应该读取为“ mapZone”。

#Region "Help:  Introduction to the Script Component"
' The Script Component allows you to perform virtually any operation that 
can be accomplished in
' a .Net application within the context of an Integration Services data 
flow.

' Expand the other regions which have "Help" prefixes for examples of 
specific ways to use
' Integration Services features within this script component.
#End Region

#Region "Imports"
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
'
Imports System.Xml
#End Region

' This is the class to which to add your code.  Do not change the name, 
attributes, or parent
' of this class.
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute>
<CLSCompliant(False)>
Public Class ScriptMain
Inherits UserComponent

Private url As String = ""

Public Overrides Sub PreExecute()
    MyBase.PreExecute()
    '
    System.Net.ServicePointManager.SecurityProtocol = 
Net.SecurityProtocolType.Tls12
    Dim x As HttpClientConnection100 = 
CType(Connections.Source.AcquireConnection(Nothing), 
HttpClientConnection100)
    url = x.ServerURL.ToString
End Sub

Public Overrides Sub CreateNewOutputRows()

    Me.ComponentMetaData.FireInformation(1, "Connection", url, "", 0, 
True)

    Try

        Dim settings As New XmlReaderSettings()

        With settings
            .DtdProcessing = DtdProcessing.Parse
        End With
        settings.IgnoreWhitespace = True
        Using reader As XmlReader = XmlReader.Create(url, settings)

            While (reader.Read())

                If (reader.Name = "mapZone") Then

                    Dim types As String = reader.GetAttribute("type")
                    Dim territory As String = 
reader.GetAttribute("territory")
                    Dim other As String = reader.GetAttribute("other")

                    Dim shred() As String = Split(types)

                    For i As Integer = 0 To shred.Length - 1

                        Dim type As String = shred(i).ToString

                        With Output0Buffer
                            .AddRow()
                            .terrritory = territory
                            .type = type
                            .other = other
                        End With

                    Next

                End If

            End While

        End Using

    Catch ex As Exception

        ComponentMetaData.FireError(1, "UNICODE", 
ex.InnerException.ToString, "", 0, True)

    End Try

End Sub

End Class

应该获取其中reader.name = mapZone的数据以获取其他属性,地域和类型。

0 个答案:

没有答案