View Single Post
  #1 (permalink)  
Old December 13th, 2010, 12:32 PM
AnujAngural AnujAngural is offline
Registered User
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating XML with Linq To XML

Hello friends,
I am new to XML,so please help me out

Following is my code-->

Response.ContentType = "text/xml";

XNamespace ns = "";
XDocument books = new XDocument(new XElement(ns + "bookstore",
new XElement(ns + "book",
new XAttribute("publication", "pub123"),
new XAttribute("ISBN", "123"),
new XElement(ns + "Title", "ASP.NET 4.0"),
new XElement(ns + "Price", "Rs 100"),
new XElement(ns + "Author",
new XElement(ns + "First-Name", "Anuj"),
new XElement(ns + "Last-Name", "Angural")))));


catch (Exception ex)


I am getting following error in IE--->

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.


Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'http://localhost:3018/XML/Default2.aspx'....

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""&...