dataset reading XML error...

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

  1. OhioHoya

    OhioHoya

    Joined:
    Apr 26, 2010
    Messages:
    1
    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. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jacksu
    Replies:
    0
    Views:
    1,317
    jacksu
    Mar 2, 2004
  2. =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=

    Dataset - Error

    =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=, Jun 9, 2004, in forum: MCSD
    Replies:
    2
    Views:
    880
    Daniel Joskovski
    Jun 9, 2004
  3. fullblown
    Replies:
    0
    Views:
    1,220
    fullblown
    Sep 20, 2006
  4. Diplom Kaufmann Hinrichs -  Siegert, Knut

    Help in analysing and optimizing XML Data reading urgently (in the next weeks) required.

    Diplom Kaufmann Hinrichs - Siegert, Knut, Sep 16, 2007, in forum: Computer Support
    Replies:
    2
    Views:
    4,377
    Diplom Kaufmann Hinrichs - Siegert, Knut
    Sep 16, 2007
  5. vbcheerful

    large dataset to xml in vb.net

    vbcheerful, Apr 9, 2008, in forum: Software
    Replies:
    0
    Views:
    1,396
    vbcheerful
    Apr 9, 2008
Loading...

Share This Page