I have a .aspx page that I want to return a dynamic XML formatted document ie built from database records.
If I view the page direct, the XML appears fine in the browser.
However, if I try and use it as the datasource for an xml control, I get the error "Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2" which I presume relates to the .aspx page declaration
The code for generating the XML is:-Code:<%@ Page Language="VB" CodeFile="customerListXML.aspx.vb" Inherits="feeds_customerListXML" ContentType="text/xml" %>
I've tried googling and come up with a couple of sites that suggest unregistering and the re-registering .NET which I've tried but with no luck.Code:Sub Page_Load() Dim objWriter As XmlTextWriter = New XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8) objWriter.Indentation = True objWriter.WriteStartDocument() objWriter.WriteStartElement("customers") Dim customerList As List(Of Customer) = Customer.GetCustomerList(newUser, newCompany) For Each item As Customer In customerList objWriter.WriteStartElement("customer") objWriter.WriteElementString("ref", item.ref) objWriter.WriteElementString("surname", item.lastname) objWriter.WriteElementString("forename", item.firstname) If item.addList.Count = 0 Then objWriter.WriteElementString("postcode", String.Empty) Else objWriter.WriteElementString("postcode", item.addList(0).postcode) End If objWriter.WriteElementString("link", "/customers/view/" & item.ref & "/") objWriter.WriteEndElement() Next objWriter.WriteEndElement() objWriter.WriteEndDocument() objWriter.Flush() End Sub
I used this article ASP.NET.4GuysFromRolla.com: Creating XML Documents with the XmlTextWriter Class to create the XML file.
Any ideas how I can fix this?



LinkBack URL
About LinkBacks
Reply With Quote


Bookmarks