Two methods are provided to compile the aspx page (the xml document is displayed on the page)

Source: Internet
Author: User

Method 1:

Instance:

<% @ 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 ("Guangzhou ")? "Guangzhou": Eval ("VisaTypeName"). ToString (). Contains ("Shanghai ")? "Shanghai": "Beijing" %> '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-000000000-00001).html", Eval ("CountryE_Name "). toString (). toLower (). replace ("", "_"), Eval ("TypeID") %> </Url>
</Item> </ItemTemplate>
</Asp: Repeater>
</VisaList>

Method 2:

Instance:

<% @ 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 ());

}

 

Differences between the two methods:

The first method adopts the binding method, which is the page output note. The first method is to ensure that the xml format mark must follow the xml format, that is, the line feed is used, do not change the line feed !!!

The second method is to generate a node in the background, return a negative value to the node, and output the concatenated string to the page.

From: qingqing Column

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.