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

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())

<?xml version="1.0"?>
    <phone>999 999-9999</phone>
    <address>9999 York St.</address>
    <phone>415 986-7020</phone>
    <address>No Name St.</address>


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