not sure what i'm suppose to gather from that. i appreciate the response, but i'm not looking for a basic tutorial.
Main Topics
Browse All TopicsI'm trying to populate a table with an XML file however i keep getting the error:
System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1
I've done some googling but didn't find much out on the cause. A lot of people pointed to making sure the folder has anonymous access (which it does), so i'm not sure what else to try. I'll post a bit of code for your viewing pleasure. (keep in mind this is my first work with xml, so the easiest solution, may in fact be the correct one)
===========
news.xml
===========
<?xml version="1.0" encoding="utf-8" ?>
<news>
<article>
<title>My First XML News!</title>
<link>http://localhost/New
<description>An in-depth article about the perils of XML</description>
<summaryImageTitle>Article
<summaryImageURL>http://lo
<pubDate>Mon 11 Jul 2005 9:45:00 EST</pubDate>
</article>
</news>
**************************
===============
SamplePage.aspx.vb (Sub_Load method only)
===============
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim reader As New XmlTextReader(New StringReader("http://local
Dim sb As New StringBuilder()
Dim localName As String
Dim title As String
Dim link As String
Dim description As String
Dim sumImgTitle As String
Dim sumImgURL As String
Dim pubDate As String
Dim data As String
reader.WhitespaceHandling = WhitespaceHandling.None
reader.Read() '<<<<>>>>************* This is the line the errors occurs on
While Not reader.LocalName.Equals("N
reader.Read()
While Not reader.LocalName.Equals("i
localName = reader.LocalName
reader.Read()
data = reader.ReadString
If localName.Equals("title") Then
title = data
ElseIf localName.Equals("link") Then
link = data
ElseIf localName.Equals("descript
description = data
ElseIf localName.Equals("summaryI
sumImgTitle = data
ElseIf localName.Equals("summaryI
sumImgURL = data
ElseIf localName.Equals("pubDate"
pubDate = data
End If
End While
reader.Read()
End While
reader.Close()
End If
End Sub
**************************
The plan after getting this done was to use a stringbuilder to append all the data, and add it to a literal control inside SamplePage.aspx. Any ideas on how to get this stuff read in without getting this error?
Thanks
-Matt
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Bob - I would like the values.
NetSlut - Yeah, i know about the dataset, but i'm not sure how easy it would be to use in my situaion. i have a layout i want the data to conform to, and not all of the information will always be in the xml file. Is there a huge performance gain of populating a dataset and spitting things back out in a <%# Container.DataItem...... %> tag? or would just building a string (using stringbuilder of course) and writing it to a literal be fine since there will always be less than 5 items read from the xml file.
As far as the error goes (and the original aim of the post), I changed one line that has seemed to fix my error permanently:
Dim reader As New XmlTextReader(New StringReader("http://local
to:
Dim reader As New XmlTextReader("http://loca
well its been well over a week and no one is responding so i assume you either don't know or have forgotten about this. But since the i solved the original question and it is only the sub question that went unanswered, i will just split the points. If you have any commments and would like to leave them i'll still monitor this. Thanks
i don't think you will notice the performance difference between DataSet.ReadXml() and XMLReader ... unless you have thousands of rows ...
you could try it yourself by tracing , and looking at the time taken for each method ..
I think the biggest difference is that XML objects (XMLReader, etc) give you more precise control over what you want to do ...
If DataSet.ReadXml() isn't enough, use XMLReader, otherwise, don't ... :-)
Business Accounts
Answer for Membership
by: Tim_HeldbergPosted on 2005-07-11 at 10:24:00ID: 14414261
Try http://www.w3schools.com/a spnet/aspn et_xml.asp