Hi,
like i wrote in my subject, i want to ask how to show xml file in web page?
for example i have xml file like this.
title="The Iliad and The Odyssey"
price="12.95">
comment="Best translation I've read." />
comment="I like other versions better." />
i can show this xml structure with xmldatasource and connected with datagrid or else.
but i have problem if i want to show xml file with this structure.
for this i just can show the first line
i dont know why? or maybe there are some structure problem in my second xml?
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jun 23, 2012, 6:33 AM
Display xml file using xml control.
For that we have to add an Xml control, xml file and XSLTFile.
First add a xml file to the webform and write the below code to that file and name that file as
Student.xml
Then add an Xslt file to the webform. To display the student.xml file in tabular form, which will, appears in the webform,we write the below code in this Xslt file.
Student. Xslt
StudentDetails
Default.aspx code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Pagetitle>
head>
<body>
<form id="form1" runat="server">
<div>
div>
<asp:Xml ID="Xml1" runat="server">asp:Xml>
form>
body>
html>
Default.aspx.vb code
Imports System.Data
Imports System.Xml
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim ds As New DataSet
ds.ReadXml(MapPath("student.xml"))
Xml1.Document = New XmlDataDocument(ds)
Xml1.TransformSource = "student.xslt"
End If
End Sub
End ClassThanks