dataset reading XML error...

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

  1. OhioHoya


    Apr 26, 2010
    Likes Received:
    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.ContentType = "text/xml"
    Response.ContentEncoding = Encoding.UTF8

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

    With xtwFeed
    ' Start the document

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

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

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

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

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

    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">

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

    <title>Untitled Page</title>

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


    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. 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.