vb.net XmlTextReader falls into this exception

Hi;

I am trying to parse the following xml document with the following code. I am ending up with this error;

XmlTextReader 'debuggerDisplay Proxy' is a type and cannot be used as an expression.

My aim is to store id attributes in the file to a SortedList. Can you help?

<?xml version="1.0" encoding="UTF-8"?>
<context>http://localhost/SAML2IdentityProvider/</context>
<layout>
<user type="standard">
   <sequence>
   <behavior type="click" on="a" id="link1">
   </behavior>
   <behavior type="click" on="a" id="link2">
   </behavior>
   </sequence>
</user>
</layout>

Open in new window


 Protected Function xmlParse() As Boolean

        Dim m_xmlr As XmlTextReader
        'Create the XML Reader
        m_xmlr = New XmlTextReader("C:\behavior.xml")
        'Disable whitespace so that you don't have to read over whitespaces
        m_xmlr.WhitespaceHandling = WhitespaceHandling.None
        'read the xml declaration and advance to layout tag
        m_xmlr.Read()
        m_xmlr.Read()

        'read the layout tag
        m_xmlr.Read()
        'Load the Loop
        While Not m_xmlr.EOF
            'Go to the user tag
            m_xmlr.Read()
            'if not start element exit while loop
            'If Not m_xmlr.IsStartElement() Then
            '   Exit While
            'End If
            'Get the User Type Attribute Value
            Dim userTypeAttribute = m_xmlr.GetAttribute("type")
            'Read sequence element
            m_xmlr.Read()

            'Read behavior element
            m_xmlr.Read()
            Dim behavior1 = m_xmlr.GetAttribute("type")

            Dim i As Integer
            For i = 0 To mySL.Count - 1

                If Not behavior1.Equals(mySL.GetKey(i)) Then
                    Return False
                    Exit While
                End If

                ' Console.WriteLine(ControlChars.Tab & "{0}:" & ControlChars.Tab & _
                '   "{1}", mySL.GetKey(i), mySL.GetByIndex(i))
            Next i
            Console.Write(vbCrLf)
        End While
        'close the reader
        m_xmlr.Close()
        Return True
    End Function

Open in new window

LVL 12
jazzIIIloveAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
You don't have valid XML. A valid XML document cannot have two root nodes. Yours does:  <context /> and <layout />.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.