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