XML Parsing Error: junk after document element

Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2007
Posts: 13
Reputation: Dha_King is an unknown quantity at this point 
Solved Threads: 0
Dha_King Dha_King is offline Offline
Newbie Poster

XML Parsing Error: junk after document element

 
0
  #1
Jan 1st, 2008
Hello everybody, this is a sad story really, 3 days ago my code worked fine now it don't. I get this error "XML Parsing Error: junk after document element
Location: http://localhost:1218/projektCsharp/Default.aspx
Line Number 11, Column 1:"

If i try to remove or mark out
"<?xml version="1.0" encoding="utf-8" ?>
<guestbook xmlns="http://me.com/guest.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://me.com/ guest.xsd"> from the XML file then i get a HTTP 403 Forbidden error.

What can be wrong? thx in advance. //DK
PS it supposed to be a simple guestbook.






</guestbook>"

XML FILE
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8" ?>
  2.  
  3. <guestbook xmlns="http://me.com/guest.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://me.com/ guest.xsd">
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. </guestbook>
XSD FILE
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="utf-8" ?>
  2.  
  3. <xsd:schema id="guest" targetNamespace="http://me.com/guest.xsd"
  4. elementFormDefault="qualified"
  5. xmlns="http://www.w3.org/2001/XMLSchema"
  6. xmlns:mstns="http://me.com/guest.xsd"
  7. xmlns:xsd="http://www.w3.org/2001/guest.xsd">
  8.  
  9. <xsd:element name="Guests" >
  10. <xsd:complexType>
  11. <xsd:choice maxOccurs="unbounded">
  12. <xsd:element name="Guest">
  13. <xsd:complexType>
  14. <xsd:sequence>
  15. <xsd:element name="Name" type="xsd:string" minOccurs="0" />
  16. <xsd:element name="Country" type="xsd:string" minOccurs="0" />
  17. <xsd:element name="Email" type="xsd:string" minOccurs="0" />
  18. <xsd:element name="Comments" type="xsd:string" minOccurs="0" />
  19. <xsd:element name="DateTime" type="xsd:string" minOccurs="0" />
  20. </xsd:sequence>
  21. </xsd:complexType>
  22. </xsd:element>
  23. </xsd:choice>
  24. </xsd:complexType>
  25. </xsd:element>
  26. </xsd:schema>


DEFAULT PAGE just the page load
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. string email="member69@hotmail.com";
  4. string name="joe doe";
  5. string country="helvetia";
  6. string comments="funkis??";
  7. string datetime="2minutestomidnight";
  8.  
  9. XmlWriterSettings settings = new XmlWriterSettings();
  10. settings.Indent = true;
  11. settings.NewLineOnAttributes = true;
  12. Response.ContentType = "text/xml";
  13. XmlSerializerFactory factory = new XmlSerializerFactory();
  14. using (XmlWriter writer = XmlWriter.Create(Response.OutputStream, settings))
  15. {
  16. writer.WriteStartDocument();
  17. writer.WriteStartElement("Guests");
  18. writer.WriteStartElement("Guest");
  19. writer.WriteStartAttribute("Name");
  20. writer.WriteValue(name);
  21. writer.WriteEndAttribute();
  22. writer.WriteStartAttribute("Country");
  23. writer.WriteValue(country);
  24. writer.WriteEndAttribute();
  25. writer.WriteStartAttribute("Email");
  26. writer.WriteValue(email);
  27. writer.WriteEndAttribute();
  28. writer.WriteStartAttribute("Comments");
  29. writer.WriteValue(comments);
  30. writer.WriteEndAttribute();
  31. writer.WriteStartAttribute("DateTime");
  32. writer.WriteValue(datetime);
  33. writer.WriteEndAttribute();
  34. writer.WriteEndElement();
  35. writer.WriteEndElement();
  36. writer.WriteEndDocument();
  37. }
  38.  
  39.  
  40. }
Last edited by Dha_King; Jan 1st, 2008 at 2:48 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 13
Reputation: Dha_King is an unknown quantity at this point 
Solved Threads: 0
Dha_King Dha_King is offline Offline
Newbie Poster

Re: XML Parsing Error: junk after document element

 
0
  #2
Jan 1st, 2008
I forgott

DEFAULT.ASPX
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7. <title>Untitled Page</title>
  8. </head>
  9. <body>
  10. <form id="form1" runat="server">
  11. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />&nbsp;&nbsp;
  12. </form>
  13. </body>
  14. </html>

It seems to work if i comment out the default.aspx, i have no idea what's wrong here. Please help me. =)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the XML, XSLT and XPATH Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC