两种方法接口aspx页面的编写(页面展示xml文档)

第一种方法:

实例:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XMLQunar.aspx.cs" Inherits="Byecity2009.Visa.WebApp.XMLQunar"ContentType="text/xml"%>
<%@ Import Namespace="Byecity2009.Visa.Web" %>
<%@ OutputCache VaryByParam="none" Duration="1800" %><?xml version="1.0" encoding="utf-8"?>
<VisaList><asp:Repeater ID="rpAllVisa" runat="server" DataSource="<%# AllVisaViewTable %>"><ItemTemplate>
<Item Price='<%# ShowPrice_Only(Eval("VisaXml").ToString(),"GuestPrice","CuXiaoPrice") %>' Country='<%# Eval("CountryC_Name") %>' Type='<%# Eval("VisaTypeName") %>' DealCity='<%#Eval("VisaTypeName").ToString().Contains("广州")?"广州":Eval("VisaTypeName").ToString().Contains("上海")?"上海":"北京"%>' ValidityDate='<%# SelectSingleNodeText(Eval("VisaXml").ToString(),"ValidityDate") %>' SettleDay='<%# SelectSingleNodeText(Eval("VisaXml").ToString(),"SettleDay") %>' IntendingDay='<%# SelectSingleNodeText(Eval("VisaXml").ToString(),"IntendingDay") %>' IsExam='<%# SelectSingleNodeText(Eval("VisaXml").ToString(),"IsExam") %>' VisaRequest='<%# BuildVisaRequest( Eval("VisaXml").ToString() ) %>' letter="" Category="<%# GetCategoryStr(Eval("BasicTypeName").ToString()) %>">
<Confine><%# SelectSingleNodeText(Eval("VisaXml").ToString(),"Confine") %></Confine>
<Url><%# string.Format( "http://visa.byecity.com/visa-{0}-{1}.html", Eval( "CountryE_Name" ).ToString().ToLower().Replace(" ","_"), Eval( "TypeID" ) )%></Url>
</Item></ItemTemplate>
</asp:Repeater>
</VisaList>

第二种方法:

实例:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LineDetail.aspx.cs" Inherits="WebInterFace.Group.LineDetail" ContentType="text/xml" %>

<%=sbContent %>

CreateContect();

function CreateContect(){

DataSet list = bll.GetGroupInfoListForInterFace(strwhere, " ");

if (list != null && list.Tables[0].Rows.Count > 0)
{
XmlNode node = xml.CreateNode(XmlNodeType.XmlDeclaration, "", "");
node.InnerText += " encoding=\"utf-8\"";
xml.AppendChild(node);

XmlNode dujiasnode = xml.CreateElement("dujia_xianlus");


for (int i = 0; i < list.Tables[0].Rows.Count; i++)
{
string GropID = string.Empty;
LineID = list.Tables[0].Rows[i]["ID"].ToString();

Byecity2011.WebSite.Model.Prod_ProductGroup group = bll.GetGroupProductDetailByID(Convert.ToInt32(LineID));

XmlNode dujianode = xml.CreateElement("dujia_xianlu");

XmlNode TypeNode = xml.CreateElement("type");
TypeNode.InnerText = "1";
XmlNode rangetypeNode = xml.CreateElement("rangetype");
rangetypeNode.InnerText = "2";
XmlNode traffictypeNode = xml.CreateElement("traffictype");
traffictypeNode.InnerText = "11";
XmlNode LinkNode = xml.CreateElement("link");
LinkNode.InnerText = path + "Line-" + LineID + ".html";
XmlNode CodeNode = xml.CreateElement("code");
CodeNode.InnerText = LineID;

dujianode.AppendChild(TypeNode);
dujianode.AppendChild(rangetypeNode);
dujianode.AppendChild(traffictypeNode);
dujianode.AppendChild(LinkNode);
dujianode.AppendChild(CodeNode);

xml.AppendChild(dujiasnode);

sbContent.Append(xml.InnerXml.ToString());

}

两种方法的区别:

第一种方法 采用的是绑定方式就是页面输出 注意事项:第一种,是必须保证那个xml格式标示必须是按着xml格式走的,即该换行就换行,不该换行不用换!!!

第二种方法,主要的方法 就是 利用后台生成节点,给节点负值,最后将拼接成的字符串输出到页面上。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值