Read XML file and output to client : XML Output « XML « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » XML » XML Output 
Read XML file and output to client

<%@ Page Language="C#"%>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Schema" %>

<script runat="server">    
    void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        string xmlPath = MapPath("Authors.xml");            
        XmlReader reader = XmlReader.Create(xmlPath);
        XmlSchemaSet schemaSet = new XmlSchemaSet();
        XmlSchemaInference schema = new XmlSchemaInference();
        schemaSet = schema.InferSchema(reader);
        foreach (XmlSchema schemaObj in schemaSet.Schemas())
        {
            schemaObj.Write(Response.Output);
        }      
    }
  
</script>


<%--
<?xml version="1.0"?>
<authors>
  <author>
    <authorID>000-00-0001</authorID>
    <lastName>Nancy</lastName>
    <firstName>Lee</firstName>
    <phone>999 999-9999</phone>
    <address>9999 York St.</address>
    <city>Regina</city>
    <state>LA</state>
    <zip>99999</zip>
    <contract>true</contract>
  </author>
  <author>
    <authorID>000-00-0002</authorID>
    <lastName>First</lastName>
    <firstName>Last</firstName>
    <phone>415 986-7020</phone>
    <address>No Name St.</address>
    <city>Vancouver</city>
    <state>BC</state>
    <zip>88888</zip>
    <contract>true</contract>
  </author> 
</authors>


--%>
           
       
Related examples in the same category
1.Use XmlDocument (DOM) to load xml file and output to browser
2.Load XML from string and output to browser
3.Read and format XML data into HTML
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.