dataset reading XML error...

Discussion in 'General Computer Support' started by OhioHoya, Apr 26, 2010.

  1. OhioHoya

    OhioHoya

    Joined:
    Apr 26, 2010
    Messages:
    1
    Likes Received:
    0
    Okay - this is driving me crazy because I really need to get this working and have not been able to find the solution. Here is my setup:

    1. I have an aspx page that simply generates an xml output stream. Code:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Response.Clear()
    Response.ClearHeaders()
    Response.ContentType = "text/xml"
    Response.ContentEncoding = Encoding.UTF8

    Dim xtwFeed As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)

    With xtwFeed
    ' Start the document
    .WriteStartDocument()

    'Do a sql data read and loop here. (will hard-code for now)
    .WriteStartElement("News")
    .WriteStartElement("NewsItem")
    .WriteElementString("NewsID", "1")
    .WriteElementString("Title", "Hobbits")
    .WriteElementString("Image", "hobbits.jpg")
    .WriteElementString("Text", "Hobbits fuel record DVD sales")
    .WriteEndElement()

    .WriteStartElement("NewsItem")
    .WriteElementString("NewsID", "2")
    .WriteElementString("Title", "Net favorite")
    .WriteElementString("Image", "towers.jpg")
    .WriteElementString("Text", "Online critics reward Two Towers")
    .WriteEndElement()

    .WriteStartElement("NewsItem")
    .WriteElementString("NewsID", "3")
    .WriteElementString("Title", "Here to stay")
    .WriteElementString("Image", "cd.jpg")
    .WriteElementString("Text", "Industry boss warning on illegal music")
    .WriteEndElement()

    .WriteStartElement("NewsItem")
    .WriteElementString("NewsID", "4")
    .WriteElementString("Title", "Eye spy")
    .WriteElementString("Image", "Eye.jpg")
    .WriteElementString("Text", "Pupils to be eye scanned at school")
    .WriteEndElement()

    ' Close all tags
    .WriteEndElement() ' News
    .WriteEndDocument() ' Document
    .Flush()
    .Close()
    End With
    Response.End()

    End Sub

    2. The html code on this page is:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="NewsFeed.aspx.vb" Inherits="NewsFeed" %>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">

    <html>
    <head id="Head1" runat="server">

    <title>Untitled Page</title>
    </head>
    <body>

    <form id="form1" runat="server">
    <div>

    </div>
    </form>
    </body>
    </html>


    3. The page that should be reading this xml stream has the following code:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim ds As New System.Data.DataSet

    ds.ReadXml("NewsFeed.aspx") ' <=== The following error happens here:
    'Exception Details: System.Xml.XmlException: Name cannot begin with the '%' character, hexadecimal value 0x25. Line 2, position 2.

    '(more code here but doesn't have anything to do with the error)

    End Sub


    Okay, I think I've tried almost every combination in changing these files. I have deleted the <html>, <head> and <body> tag areas. I have moved code around like crazy but still nothing works. If I call the xml (aspx) page in a browser it looks to work just fine. I have not moved this code to an actual web server - I have only been running this via dev. This shouldn't be an issue because I have a copy of xml output in a separate file called newsfeed.xml which works just fine on the dataset loadxml method. It just seems that I can't get rid of some prefix that is being sent when the NewsFeed.aspx page is called...

    Can someone please help? I know this must be a simple thing to do and maybe I'm having a brain fart on this but I can't keep losing precious days of development on this problem.

    Thanks, in advance, for the help!
     
    OhioHoya, Apr 26, 2010
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.