Results 1 to 5 of 5

Thread: Declaring A New XML Text Reader

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Location
    North East England, UK
    Posts
    9

    Declaring A New XML Text Reader

    I always get this error when trying to create a xmltextreader:

    C:\Documents and Settings\Timothy\My Documents\Visual Studio Projects\Amazon\Form1.vb(65): Overload resolution failed because no accessible 'New' accepts this number of arguments.

    Code:
    Imports System.Xml
    Public Class Form1
        Inherits System.Windows.Forms.Form
    
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents Button1 As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.Button1 = New System.Windows.Forms.Button
            Me.SuspendLayout()
            '
            'Button1
            '
            Me.Button1.Location = New System.Drawing.Point(56, 40)
            Me.Button1.Name = "Button1"
            Me.Button1.Size = New System.Drawing.Size(96, 24)
            Me.Button1.TabIndex = 0
            Me.Button1.Text = "Button1"
            '
            'Form1
            '
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(256, 238)
            Me.Controls.Add(Me.Button1)
            Me.Name = "Form1"
            Me.Text = "Form1"
            Me.ResumeLayout(False)
    
        End Sub
    
    #End Region
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim tRead As XmlTextReader = New XmlTextReader
    
    
    
    
        End Sub
    End Class

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    The default (no argument) contstructor for XmlTextReader is Protected. Maybe try using one of the Public constructors.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Location
    North East England, UK
    Posts
    9
    Could I see an example of how that is done?

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Check out MSDN - lots of good examples. But here's a snippet:
    VB Code:
    1. Dim sr As New StreamReader("c:\temp\myfile.xml")
    2.         Dim xtr As New XmlTextReader(sr)
    3.         While xtr.Read
    4.             Debug.WriteLine(xtr.LineNumber)
    5.         End While
    6.         xtr.Close()
    7.         sr.Close()

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Location
    North East England, UK
    Posts
    9
    Great Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width