Wondering what is it that I am doing wrong (and how I can fix it) ... I am trying to learn how to read XML file and created a little program below to start testing what I have read but keep getting error "Data at the root level is invalid. Line 1, position 1"
The line where the error is coming from is the line "xmldoc.LoadXml(strFile)".. any ideas?
Thank you so much for all the help you could give.
Gratefully,
Matt
Below is the content of the XML file which is located in e:\xml\mama.xml:Code:Private Sub cmdReadXML_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReadXML.Click Dim clsk As New clsHx clsk.ReadXML("e:\xml\mama.xml") End Sub Below is the a subroutine in my clsHx class: Public Sub ReadXML(ByVal strFile As String) Dim xmldoc As New XmlDocument xmldoc.LoadXml(strFile) MsgBox(xmldoc.GetElementsByTagName("myfirstdata")) MsgBox(xmldoc.GetElementsByTagName("mySecondData")) End Sub
Code:<?xml version="1.0" ?> <myData> <myrecord> <myfirstdata>String for my second element</myfirstdata> <mySecondData>Second data element here</mySecondData> </myrecord> <myrecord> <myfirstdata>record2 for my second element</myfirstdata> <mySecondData>record2mySec Second data element here</mySecondData> <myThirdData>recorderData data element here</myThirdData> </myrecord> </myData>




Reply With Quote