+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22

Thread: Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2

    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
    Code:
    <%@ Page Language="VB" CodeFile="customerListXML.aspx.vb" Inherits="feeds_customerListXML" ContentType="text/xml" %> 
    The code for generating the XML is:-
    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'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.

    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?

  2. #2
    Ask Me About Dragons :D Shadow Wizard has a spectacular aura about Shadow Wizard has a spectacular aura about Shadow Wizard's Avatar
    Join Date
    Jul 2008
    Location
    Israel
    Posts
    795
    Blog Entries
    2
    Real Name
    Yahav
    Rep Power
    5

    change the page Content Type to be XML type (I think "text/XML" but not sure)
    by setting the Response.ContentType property.
    hopefully this will tell the control it's indeed getting XML..

  3. #3
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Shadow Wizard View Post
    change the page Content Type to be XML type (I think "text/XML" but not sure)
    by setting the Response.ContentType property.
    hopefully this will tell the control it's indeed getting XML..
    I have set the ContentType to text/xml in the page control directive.

    Is there something else I should add?

  4. #4
    Ask Me About Dragons :D Shadow Wizard has a spectacular aura about Shadow Wizard has a spectacular aura about Shadow Wizard's Avatar
    Join Date
    Jul 2008
    Location
    Israel
    Posts
    795
    Blog Entries
    2
    Real Name
    Yahav
    Rep Power
    5

    Quote Originally Posted by richyrich View Post
    I have set the ContentType to text/xml in the page control directive.

    Is there something else I should add?
    hmm.. can't see anything else.
    can you post code for the XML control that consume the page and
    generate that error you mentioned?

  5. #5
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    In my content page I have:
    Code:
    <asp:Xml ID="xmlClientList" runat="server"/> 
    And in code behind I was using
    Code:
    xmlClientList.DocumentSource = "/feeds/CustomerListXML.aspx"
    xmlClientList.TransformSource = "/xslt/customers_full_list.xslt"
     

    Is that what you were after?

    <edit>If I change then DocumentSource to "~/App_Data/client_test.xml" which is just a static XML file, it works fine.</edit>

  6. #6
    Ask Me About Dragons :D Shadow Wizard has a spectacular aura about Shadow Wizard has a spectacular aura about Shadow Wizard's Avatar
    Join Date
    Jul 2008
    Location
    Israel
    Posts
    795
    Blog Entries
    2
    Real Name
    Yahav
    Rep Power
    5

    maybe the problem is with MIME type.. the server probably send something
    for .aspx and the XML control ignores the Content Type header.

    try the following:
    1. change /feeds/CustomerListXML.aspx to be /feeds/CustomerListXML.myxml
    2. in IIS map extension .myxml to go through the ASP.NET dll (same like .aspx)
    3. in IIS add MIME Type for .myxml that will send "text/XML"

    bit complicated but might work.

  7. #7
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Get the same error...

    "Name cannot begin with the '%' character, hexadecimal value 0x25. Line 1, position 2."

    Should I be changing the name / extension of the code behind file as well?

    If I try and browse to the xml file with the new extension I get an error
    Code:
     
    The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. A name was started with an invalid character. Error processing resource 'http://www.*********.com/feeds/customerListXM...
    <%@ Page Language="VB" CodeFile="clientListXML.aspx.vb" Inherits="feeds_clientListXML" %>
    -^ 

  8. #8
    Ask Me About Dragons :D Shadow Wizard has a spectacular aura about Shadow Wizard has a spectacular aura about Shadow Wizard's Avatar
    Join Date
    Jul 2008
    Location
    Israel
    Posts
    795
    Blog Entries
    2
    Real Name
    Yahav
    Rep Power
    5

    sorry, out of ideas.... I would try to explore alternative to the XML control.

  9. #9
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Quote Originally Posted by Shadow Wizard View Post
    sorry, out of ideas.... I would try to explore alternative to the XML control.
    Yeah, I would normally just bind it to a list(of ) object, but I thought I would try and generate XML instead to include some web standard practices...

    I would have thought something like this would be fairly common practice, to generate an XML file on the fly and use it in a normal page...Am I doing something out of the ordinary here?

  10. #10
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    I'm wondering if this is something that the VirtualPathProvider would be useful for...
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. MS Access: remove song from media player by position
    By sbenj69 in forum Microsoft Access
    Replies: 8
    Last Post: February 28th, 2011, 11:25 AM
  2. Trying to find the first space " " character...
    By bryceowen in forum PHP Development
    Replies: 9
    Last Post: February 27th, 2009, 01:23 PM
  3. seprate coulmn from line.
    By guddu in forum ASP Development
    Replies: 9
    Last Post: July 17th, 2008, 09:30 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO