遇到了很多问题呀,以前学了点xsl,
是这个名称空间:<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
可是.net不支持这个,只支持xslt ,名称空间为:<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
必须改成xslt,但是xslt和 xsl不一样,有些xsl代码在xslt中不被支持。比如:
在xsl中有<xsl:if match > 和 <xsl:when match > 用来操作元素
<xsl:if test > 和 <xsl:when test > 用来操作属性
可是在xslt中所有的<xsl:if match > 和 <xsl:when match> 都不好用了,
只能用<xsl:if test >和<xsl:when test> 而且无论是元素还是属性,都用它。
真的和让我恼火。差了很多资料才搞定(笨吗,没办法)。
还有原来的order-by排序属性也不能用了,要用<xsl:sort select=“字段“ order=“descending|ascending“/>
另外xsl中不能正确解释xml中的带有标记的数据
比如xml中有这样的数据<xxx><a href=“a.aspx“>xx</a></xxx>
在xsl中格式化后显示 xx ,但是没有连接效果。
最后没办法,这种情况,我都用属性的方法搞定,也就是在xml中指保存地址,如
<xxx>a.aspx</xxx>
在xsl中:
<a>
<xsl:attribute name=“href“>
<xsl:value-of select=“xxx“/>
</xsl:attribute>
</a>
另外,可以用<xsl:value-of select=“count(???)“/>来计算记录数,当然这里的count可以换成其他支持的统计函数,比如sum(求和)。
还可以这样实现交替行的效果:
<xsl:attribute name="style">
<xsl:if test="position() mod 2=0">
background-color:#909090;
</xsl:if>
</xsl:attribute>
这里的核心就是 position() mod 2
将个人信息处理到xml文件中的代码如下:
SqlConnection myConnection;
string
UserName;
string
UserID;
string
idd;
StringBuilder sbXml;
string
xmlName;
private
void
Page_Load(
object
sender, System.EventArgs e)
...
{
myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
UserID=LoveAndFriend.pMethod.getCookie("UserID")==null?"null":(string)LoveAndFriend.pMethod.getCookie("UserID");
UserName=LoveAndFriend.pMethod.getCookie("UserName")==null?"null":(string)LoveAndFriend.pMethod.getCookie("UserName");
myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
idd=UserName;
if(idd=="")
...{
Response.Write("请重新登录后在操作!");
Response.End();
}
xmlName="xml/" + idd + ".xml";
myConnection.Open();
if(!IsPostBack)
...{
CreateXml();
}
}
private
void
CreateXml()
...
{
SqlCommand cm = new SqlCommand();
string strInfo="";
try
...{
cm.Connection = myConnection;
SqlDataReader dr;
sbXml=new StringBuilder();
sbXml.Append("<?xml versinotallow="1.0"?> ");
string sql;
sql="select * from reg_user where username='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("载入用户信息时出错!");
}
dr.Read();
string vNickName=dr["NickName"]==null?"":dr["NickName"].ToString();
string vBirthday=dr["Birthday"]==null?"":Convert.ToDateTime(dr["Birthday"]).Year.ToString() + "年";
string vSex=dr["Sex"]==null?"":dr["Sex"].ToString();
string vRegTime=dr["reg_datetime"]==null?"":Convert.ToDateTime(dr["reg_datetime"]).ToString("yyyy-MM-dd HH:mm");
int t_id=dr["MainPage"]==null?0:Convert.ToInt32(dr["MainPage"]);
dr.Close();
if(t_id!=0)
...{
cm.CommandText="select * from personalweb where page_id=" + t_id.ToString();
}
else
...{
cm.CommandText="select * from personalweb where isDefault=1";
}
cm.CommandType=CommandType.Text;
cm.Cnotallow=myConnection;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("个人主页模板出错!");
}
dr.Read();
strInfo=dr["tmpname"]==null?"":dr["tmpname"].ToString();
if(strInfo=="")
...{
dr.Close();
throw new ArgumentException("个人主页模板出错!");
}
sbXml.Append("<?xml-stylesheet type="text/xsl" href="Template/" + strInfo + ""?> ");
dr.Close();
sbXml.Append("<Personal> ");
AddOneElement("我的网名",vNickName,"NickName");
AddOneElement("出生年月",vBirthday,"BirthDay");
AddOneElement("注册时间",vRegTime,"RegTime");
AddOneElement("性别",vSex,"Sex");
sql="select * from v_personal where username='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("载入用户信息时出错!");
}
dr.Read();
strInfo=dr["stature"]==null?"":dr["stature"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo + "厘米";
AddOneElement("身高",strInfo,"Stature");
strInfo=dr["avoirdupois"]==null?"":dr["avoirdupois"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo + "公斤";
AddOneElement("体重",strInfo,"Avoirdupois");
strInfo=dr["bloodtype"]==null?"":dr["bloodtype"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo + "型";
AddOneElement("血型",strInfo,"BloodType");
strInfo=dr["vocation"]==null?"":dr["vocation"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("从事行业",strInfo,"Vocation");
strInfo=dr["marry"]==null?"":dr["marry"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("婚姻状况",strInfo,"Marry");
strInfo=dr["title"]==null?"":dr["title"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("职业头衔",strInfo,"Title");
strInfo=dr["income"]==null?"":dr["income"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("收入水平",strInfo,"Income");
strInfo=dr["schoolage"]==null?"":dr["schoolage"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("受教育水平",strInfo,"Schoolage");
strInfo=dr["smoke"]==null?"":dr["smoke"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("是否抽烟?",strInfo,"Smoke");
strInfo=dr["drink"]==null?"":dr["drink"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("是否喝酒?",strInfo,"Drink");
strInfo=dr["aim"]==null?"":dr["aim"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("在寻觅",strInfo,"Aim");
strInfo=dr["character0"]==null?"":dr["character0"].ToString();
AddOneElement("自我介绍",strInfo,"MySelf");
string oCommnotallow=dr["common"]==null?"":dr["common"].ToString().Trim();
string oSport=dr["sport"]==null?"":dr["sport"].ToString().Trim();
string oSeasnotallow=dr["season"]==null?"":dr["season"].ToString().Trim();
string oFilm=dr["film"]==null?"":dr["film"].ToString().Trim();
string oMusic=dr["music"]==null?"":dr["music"].ToString().Trim();
string oMenu=dr["menu"]==null?"":dr["menu"].ToString().Trim();
string oColor=dr["color"]==null?"":dr["color"].ToString().Trim();
string oDress=dr["dress"]==null?"":dr["dress"].ToString().Trim();
string oLanguage=dr["language0"]==null?"":dr["language0"].ToString().Trim();
dr.Close();
if(oCommnotallow=="")
...{
AddOneElement("爱好","未透露","Common");
}
else
...{
sql="select * from b_common where id in (" + oCommon + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("爱好",strInfo,"Common");
}
if(oSport=="")
...{
AddOneElement("喜爱的运动","未透露","Sport");
}
else
...{
sql="select * from b_sport where id in (" + oSport + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("喜爱的运动",strInfo,"Sport");
}
if(oSeasnotallow=="")
...{
AddOneElement("钟爱的季节","未透露","Season");
}
else
...{
sql="select * from b_season where id in (" + oSeason + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("钟爱的季节",strInfo,"Season");
}
if(oFilm=="")
...{
AddOneElement("最爱的电影","未透露","Film");
}
else
...{
sql="select * from b_film where id in (" + oFilm + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("最爱的电影",strInfo,"Film");
}
if(oMusic=="")
...{
AddOneElement("倾心的音乐","未透露","Music");
}
else
...{
sql="select * from b_Music where id in (" + oMusic + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("倾心的音乐",strInfo,"Music");
}
if(oMenu=="")
...{
AddOneElement("偏好的口味","未透露","Menu");
}
else
...{
sql="select * from b_menu where id in (" + oMenu + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("偏好的口味",strInfo,"Menu");
}
if(oColor=="")
...{
AddOneElement("喜欢的颜色","未透露","Color");
}
else
...{
sql="select * from b_color where id in (" + oColor + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("喜欢的颜色",strInfo,"Color");
}
if(oDress=="")
...{
AddOneElement("日常的装扮","未透露","Dress");
}
else
...{
sql="select * from b_Dress where id in (" + oDress + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("日常的装扮",strInfo,"Dress");
}
if(oLanguage=="")
...{
AddOneElement("语言能力","未透露","Language");
}
else
...{
sql="select * from b_language where id in (" + oLanguage + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("语言能力",strInfo,"Language");
}
sql="select * from userlogin where username ='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
if(dr.Read())
...{
strInfo=dr["logintime"]==null?"":Convert.ToDateTime(dr["logintime"]).ToString("yyyy-MM-dd HH:mm");
AddOneElement("最近登录时间",strInfo,"LoginTime");
strInfo=dr["logincount"]==null?"":dr["logincount"].ToString();
AddOneElement("登录次数",strInfo,"LoginCount");
}
else
...{
AddOneElement("最近登录时间","","LoginTime");
strInfo=dr["logincount"]==null?"":dr["logincount"].ToString();
AddOneElement("登录次数","","LoginCount");
}
dr.Close();
sql="select * from personalPhoto where username ='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
if(dr.Read())
...{
AddOnePicLinkElement("个人形象照","ShowPhoto_p.aspx?idd=" + idd,"OriginPhoto.aspx?idd=" + idd,"SelfImg");
}
else
...{
AddOnePicLinkElement("个人形象照","images/no_photo.gif","OriginPhoto.aspx?idd=" + idd,"SelfImg");
}
dr.Close();
sql="select photo,introduce from myalbum where username ='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
sbXml.Append("<Album> ");
int t=0;
if(dr.HasRows)
...{
while(dr.Read())
...{
t++;
sbXml.Append("<Photo> ");
sbXml.Append("<FileName>" + dr["photo"].ToString() + "</FileName> ");
sbXml.Append("<Title>" + dr["introduce"].ToString() + "</Title> ");
sbXml.Append("</Photo> ");
}
sbXml.Append("<Count>" + t.ToString() + "</Count> ");
}
else
...{
sbXml.Append("<Count>0</Count> ");
}
sbXml.Append("</Album> ");
dr.Close();
AddOneElement("用户名",idd,"UserName");
AddOneLinkElement("联系方式","myleaveword/add.aspx?user_id=" + idd,"联系此会员","LinkMethod");
AddOneLinkElement("加入联络名单","myleaveword/AddToLinkmanList.aspx?u_id=" + idd,"加入联络名单","AddLinkman");
AddOneLinkElement("加入追求名单","myleaveword/AddToWooerList.aspx?u_id=" + idd,"加入追求名单","AddWooer");
AddOneLinkElement("心情日记","mydiary/personalpubdiary.aspx?user_id=" + idd,"浏览我的心情日记","LookDiary");
sbXml.Append("</Personal>");
FileStream fs = File.Open(Server.MapPath(xmlName), FileMode.Create ,FileAccess.Write,FileShare.Write);
StreamWriter writer = new StreamWriter(fs);
writer.Write(sbXml.ToString());
writer.Flush();
fs.Close();
Response.Write(sbXml.ToString());
//throw new ArgumentException("更新主页完成!");
}
catch(Exception ex)
...{
//LoveAndFriend.MyLeaveWord.pubFunction.AlertMessage(ex.Message);
Response.Write(ex.Message);
}
finally
...{
cm.Dispose();
myConnection.Close();
myConnection.Dispose();
}
}
void
AddOneElement(
string
oName,
string
oValue,
string
oElement)
...
{
sbXml.Append("<" + oElement + "> ");
sbXml.Append("<Name>" + oName + "</Name> ");
sbXml.Append("<Value>" + oValue + "</Value> ");
sbXml.Append("</" + oElement + "> ");
}
void
AddOneLinkElement(
string
oName,
string
oLink,
string
oText,
string
oElement)
...
{
sbXml.Append("<" + oElement + "> ");
sbXml.Append("<Name>" + oName + "</Name> ");
sbXml.Append("<Link>" + oLink + "</Link> ");
sbXml.Append("<Text>" + oText + "</Text> ");
sbXml.Append("</" + oElement + "> ");
}
void
AddOnePicLinkElement(
string
oName,
string
oSrc,
string
oLink,
string
oElement)
...
{
sbXml.Append("<" + oElement + "> ");
sbXml.Append("<Name>" + oName + "</Name> ");
sbXml.Append("<Src>" + oSrc + "</Src> ");
sbXml.Append("<Link>" + oLink + "</Link> ");
sbXml.Append("</" + oElement + "> ");
}
xsl模板代码如下:
<? xml versinotallow='1.0' encoding="UTF-8"
?>
<
xsl:stylesheet
version
="1.0"
xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
>
<
xsl:template
match
='/'>
<HTML
><
HEAD
><
TITLE
></
TITLE
>
<
STYLE
type
="text/css"
>
BODY {
TEXT-ALIGN: center
}
TD {
FONT-SIZE: 12px; COLOR: #666666; LINE-HEIGHT: 150%
}
</
STYLE
>
</
HEAD
>
<
BODY
text
="#000000"
bgColor
="#f2f2f2"
leftMargin
="0"
topMargin
="0"
marginheight
="0"
>
<
TABLE
height
="40"
cellSpacing
="0"
cellPadding
="0"
width
="100%"
align
="center"
bgColor
="white"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
><
A
href
="http://www.163.com/"
><
IMG
height
="30"
src
="TEMPLATE/TEMPLATE01/ne_logo2.gif"
width
="90"
border
="0"
/></
A
>
<
A
href
="http://love.163.com/"
><
IMG
height
="29"
src
="TEMPLATE/TEMPLATE01/love_logo2.gif"
width
="69"
border
="0"
/></
A
>
</
TD
>
<
TD
>
<
xsl:comment
>
-- 联络此会员 的 连接 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/LinkMethod/Link"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Personal/LinkMethod/Text"
/>
</
xsl:element
><
REMARK
>
<!--
联系方式
-->
</
REMARK
>
<
xsl:comment
>
-- 联络此会员 的 连接 end --
</
xsl:comment
>
<
xsl:comment
>
-- 加入联络名单 的 连接 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/AddLinkman/Link"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Personal/AddLinkman/Text"
/>
</
xsl:element
><
REMARK
>
<!--
加入联络名单
-->
</
REMARK
>
<
xsl:comment
>
-- 加入联络名单 的 连接 end --
</
xsl:comment
>
<
xsl:comment
>
-- 加入追求名单 的 连接 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/AddWooer/Link"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Personal/AddWooer/Text"
/>
</
xsl:element
><
REMARK
>
<!--
加入追求名单
-->
</
REMARK
>
<
xsl:comment
>
-- 加入追求名单 的 连接 end --
</
xsl:comment
>
</
TD
></
TR
></
TBODY
></
TABLE
>
<
TABLE
height
="17"
cellSpacing
="0"
cellPadding
="0"
width
="800"
align
="center"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
background
="TEMPLATE/TEMPLATE01/topdot.gif"
></
TD
></
TR
></
TBODY
></
TABLE
><
BR
/>
<
TABLE
style
="CURSOR: hand"
height
="58"
cellSpacing
="0"
cellPadding
="0"
width
="755"
align
="center"
background ="TEMPLATE/TEMPLATE01/08_1.gif"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
width
="302"
></
TD
>
<
TD
align
="left"
></
TD
></
TR
></
TBODY
></
TABLE
><
BR
/>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="800"
align
="center"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
vAlign
="top"
width
="245"
bgColor
="#f2f2f2"
><
BR
/>
<
TABLE
height
="200"
cellSpacing
="0"
cellPadding
="0"
width
="80"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
colSpan
="3"
><
IMG
height
="34"
src
="TEMPLATE/TEMPLATE01/mypptop.gif"
width
="209"
/></
TD
>
</
TR
>
<
TR
>
<
TD
width
="7"
background
="TEMPLATE/TEMPLATE01/myppleftdot.gif"
></
TD
>
<
TD
vAlign
="top"
align
="center"
>
<
xsl:comment
>
-- 个人形象照 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/SelfImg/Link"
/>
</
xsl:attribute
>
<
xsl:element
name
="img"
>
<
xsl:attribute
name
="border"
>
0
</
xsl:attribute
>
<
xsl:attribute
name
="width"
>
200
</
xsl:attribute
>
<
xsl:attribute
name
="height"
>
150
</
xsl:attribute
>
<
xsl:attribute
name
="src"
>
<
xsl:value-of
select
="Personal/SelfImg/Src"
/>
</
xsl:attribute
>
</
xsl:element
>
</
xsl:element
>
<
REMARK
>
<!--
个人形象照
-->
</
REMARK
>
<
xsl:comment
>
-- 个人形象照 end --
</
xsl:comment
>
</
TD
>
<
TD
width
="8"
background
="TEMPLATE/TEMPLATE01/mypprightdot.gif"
></
TD
></
TR
>
<
TR
>
<
TD
colSpan
="3"
><
IMG
height
="25"
src
="TEMPLATE/TEMPLATE01/mypptopdown.gif"
width
="209"
/></
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
<
BR
/><
BR
/>
<
xsl:comment
>
-- 添加联络此会员的连接 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/LinkMethod/Link"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Personal/LinkMethod/Text"
/>
</
xsl:element
><
REMARK
>
<!--
联系方式
-->
</
REMARK
>
<
xsl:comment
>
-- 添加联络此会员的连接 end --
</
xsl:comment
>
<
BR
/>
<
BR
/>
<
BR
/>
<
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/><
BR
/>
<
TABLE
height
="200"
cellSpacing
="0"
cellPadding
="0"
width
="80"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
colSpan
="3"
><
IMG
height
="34"
src
="TEMPLATE/TEMPLATE01/mypptop.gif"
width
="220"
/></
TD
></
TR
>
<
TR
>
<
TD
width
="7"
background
="TEMPLATE/TEMPLATE01/myppleftdot.gif"
></
TD
>
<
TD
>
<
TABLE
cellSpacing
="2"
cellPadding
="0"
border
="0"
valign
="top"
>
<
TBODY
>
<
TR
>
<
TD
>
<
TABLE
class
="p1"
cellSpacing
="0"
cellPadding
="0"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
colSpan
="3"
><
span
style
='cursor:hand'
onclick
='ShowBigPhoto();'><IMG
height
="170"
id
="album"
alt
="我的相册"
src
="TEMPLATE/TEMPLATE01/photoes.gif"
width
="200"
border
="0"
name
="cardpict"
/></
span
></
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
</
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
<
xsl:choose
>
<
xsl:when
test
="Personal/Album[Count > 0]"
>
<
CENTER
>
<
FORM
name
="albumlist"
>
<
SELECT
class
="p1"
onchange
="showALBUM()"
name
="albumtitle"
>
<
xsl:for-each
select
="/Personal/Album/Photo"
>
<
OPTION
value
="0"
>
<
xsl:attribute
name
="value"
>
<
xsl:value-of
select
="FileName"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Title"
/>
</
OPTION
>
</
xsl:for-each
>
</
SELECT
>
</
FORM
>
</
CENTER
>
</
xsl:when
>
</
xsl:choose
>
</
TD
>
<
TD
width
="8"
background
="TEMPLATE/TEMPLATE01/mypprightdot.gif"
>
</
TD
>
</
TR
>
<
TR
>
<
TD
colSpan
="3"
><
IMG
height
="25"
src
="TEMPLATE/TEMPLATE01/mypptopdown.gif"
width
="220"
/></
TD
>
</
TR
>
</
TBODY
></
TABLE
><
BR
/><
BR
/>
</
TD
>
<
TD
vAlign
="top"
width
="545"
><
IMG
height
="29"
src
="TEMPLATE/TEMPLATE01/topline.gif"
width
="548"
/><
BR
/>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="548"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
width
="1"
bgColor
="#aaaaaa"
rowSpan
="2"
><
SPACER
width
="1"
type
="block"
/></
TD
>
<
TD
vAlign
="top"
width
="301"
bgColor
="#e7e9eb"
>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="278"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
colSpan
="2"
><
IMG
height
="47"
src
="TEMPLATE/TEMPLATE01/grda.gif"
width
="142"
/></
TD
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/NickName/Name"
/></
TD
><
REMARK
>
<!--
我的网名
-->
</
REMARK
>
<
TD
class
="type"
width
="39%"
><
xsl:value-of
select
="Personal/NickName/Value"
/></
TD
><
REMARK
>
<!--
我的网名
-->
</
REMARK
></
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Sex/Name"
/></
TD
><
REMARK
>
<!--
性别
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Sex/Value"
/></
TD
><
REMARK
>
<!--
性别
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/BirthDay/Name"
/></
TD
><
REMARK
>
<!--
出生年月
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/BirthDay/Value"
/></
TD
><
REMARK
>
<!--
出生年月
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Stature/Name"
/></
TD
><
REMARK
>
<!--
身高
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Stature/Value"
/></
TD
><
REMARK
>
<!--
身高
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Avoirdupois/Name"
/></
TD
><
REMARK
>
<!--
体重
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Avoirdupois/Value"
/></
TD
><
REMARK
>
<!--
体重
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/BodiliForm/Name"
/></
TD
><
REMARK
>
<!--
体形
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/BodiliForm/Value"
/></
TD
><
REMARK
>
<!--
体形
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/BloodType/Name"
/></
TD
><
REMARK
>
<!--
血型
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/BloodType/Value"
/></
TD
><
REMARK
>
<!--
血型
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Language/Name"
/></
TD
><
REMARK
>
<!--
语言能力
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Language/Value"
/></
TD
><
REMARK
>
<!--
语言能力
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/City/Name"
/></
TD
><
REMARK
>
<!--
所在地
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/City/Value"
/></
TD
><
REMARK
>
<!--
所在地
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/LinkMethod/Name"
/></
TD
><
REMARK
>
<!--
联系方式
-->
</
REMARK
>
<
TD
class
="data"
>
<
xsl:comment
>
-- 添加联络此会员的连接 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/LinkMethod/Link"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Personal/LinkMethod/Text"
/>
</
xsl:element
><
REMARK
>
<!--
联系方式
-->
</
REMARK
>
<
xsl:comment
>
-- 添加联络此会员的连接 end --
</
xsl:comment
>
</
TD
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/LookDiary/Name"
/></
TD
><
REMARK
>
<!--
心情日记
-->
</
REMARK
>
<
TD
class
="data"
>
<
xsl:comment
>
-- 添加查看心情日记的连接 start --
</
xsl:comment
>
<
xsl:element
name
="a"
>
<
xsl:attribute
name
="target"
>
_blank
</
xsl:attribute
>
<
xsl:attribute
name
="href"
>
<
xsl:value-of
select
="Personal/LookDiary/Link"
/>
</
xsl:attribute
>
<
xsl:value-of
select
="Personal/LookDiary/Text"
/>
</
xsl:element
><
REMARK
>
<!--
联系方式
-->
</
REMARK
>
<
xsl:comment
>
-- 添加查看心情日记的连接 end --
</
xsl:comment
>
</
TD
>
</
TR
>
<
TR
>
<
TD
background
="TEMPLATE/TEMPLATE01/dotline.gif"
colSpan
="2"
height
="1"
><
SPACER
width
="1"
type
="block"
/></
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
<
BR
/>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="278"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
colSpan
="2"
><
IMG
height
="52"
src
="TEMPLATE/TEMPLATE01/whoami.gif"
width
="142"
/></
TD
></
TR
>
<
TR
>
<
TD
class
="type"
width
="39%"
><
xsl:value-of
select
="Personal/Marry/Name"
/></
TD
><
REMARK
>
<!--
婚姻状况
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Marry/Value"
/></
TD
><
REMARK
>
<!--
婚姻状况
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Vocation/Name"
/></
TD
><
REMARK
>
<!--
从事职业
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Vocation/Value"
/></
TD
><
REMARK
>
<!--
从事职业
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Title/Name"
/></
TD
><
REMARK
>
<!--
职业头衔
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Title/Value"
/></
TD
><
REMARK
>
<!--
职业头衔
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Income/Name"
/></
TD
><
REMARK
>
<!--
收入水平
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Income/Value"
/></
TD
><
REMARK
>
<!--
收入水平
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Schoolage/Name"
/></
TD
><
REMARK
>
<!--
受教育水平
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Schoolage/Value"
/></
TD
><
REMARK
>
<!--
受教育水平
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Smoke/Name"
/></
TD
><
REMARK
>
<!--
是否抽烟?
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Smoke/Value"
/></
TD
><
REMARK
>
<!--
是否抽烟?
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Drink/Name"
/></
TD
><
REMARK
>
<!--
是否喝酒
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Drink/Value"
/></
TD
><
REMARK
>
<!--
是否喝酒
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Common/Name"
/></
TD
><
REMARK
>
<!--
爱好
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Common/Value"
/></
TD
><
REMARK
>
<!--
爱好
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
background
="TEMPLATE/TEMPLATE01/dotline.gif"
colSpan
="2"
height
="1"
><
SPACER
width
="1"
type
="block"
/></
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
<
BR
/>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="278"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
colSpan
="2"
><
IMG
height
="50"
src
="TEMPLATE/TEMPLATE01/mychoose.gif"
width
="142"
/></
TD
>
</
TR
>
<
TR
>
<
TD
class
="type"
width
="39%"
><
xsl:value-of
select
="Personal/Aim/Name"
/></
TD
><
REMARK
>
<!--
在寻觅
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Aim/Value"
/></
TD
><
REMARK
>
<!--
在寻觅
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Sport/Name"
/></
TD
><
REMARK
>
<!--
喜爱的运动
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Sport/Value"
/></
TD
><
REMARK
>
<!--
喜爱的运动
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/Season/Name"
/></
TD
><
REMARK
>
<!--
钟情的季节
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Season/Value"
/></
TD
><
REMARK
>
<!--
钟情的季节
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Film/Name"
/></
TD
><
REMARK
>
<!--
最爱的电影
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Film/Value"
/></
TD
><
REMARK
>
<!--
最爱的电影
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Music/Name"
/></
TD
><
REMARK
>
<!--
倾心的音乐
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Music/Value"
/></
TD
><
REMARK
>
<!--
倾心的音乐
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Menu/Name"
/></
TD
><
REMARK
>
<!--
偏好的口味
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Menu/Value"
/></
TD
><
REMARK
>
<!--
偏好的口味
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Color/Name"
/></
TD
><
REMARK
>
<!--
喜欢的颜色
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Color/Value"
/></
TD
><
REMARK
>
<!--
喜欢的颜色
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
vAlign
="top"
><
xsl:value-of
select
="Personal/Dress/Name"
/></
TD
><
REMARK
>
<!--
日常的打扮
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/Dress/Value"
/></
TD
><
REMARK
>
<!--
日常的打扮
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/RegTime/Name"
/></
TD
><
REMARK
>
<!--
注册时间
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/RegTime/Value"
/></
TD
><
REMARK
>
<!--
注册时间
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/LoginTime/Name"
/></
TD
><
REMARK
>
<!--
最后登录时间
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/LoginTime/Value"
/></
TD
><
REMARK
>
<!--
最后登录时间
-->
</
REMARK
>
</
TR
>
<
TR
>
<
TD
class
="type"
><
xsl:value-of
select
="Personal/LoginCount/Name"
/></
TD
><
REMARK
>
<!--
登录次数
-->
</
REMARK
>
<
TD
class
="data"
><
xsl:value-of
select
="Personal/LoginCount/Value"
/></
TD
><
REMARK
>
<!--
登录次数
-->
</
REMARK
>
</
TR
>
</
TBODY
></
TABLE
><
BR
/><
BR
/></
TD
>
<
TD
width
="9"
background
="TEMPLATE/TEMPLATE01/vline.gif"
rowSpan
="2"
><
SPACER
width
="1"
type
="block"
/></
TD
>
<
TD
vAlign
="top"
bgColor
="#dfe4e7"
rowSpan
="2"
>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="224"
align
="center"
border
="0"
><
TBODY
>
<
TR
>
<
TD
><
IMG
height
="15"
src
="TEMPLATE/TEMPLATE01/zwjs.gif"
width
="98"
/></
TD
>
</
TR
>
<
TR
>
<
TD
><
xsl:value-of
select
="Personal/MySelf/Value"
/></
TD
><
REMARK
>
<!--
自我介绍
-->
</
REMARK
>
</
TR
></
TBODY
>
</
TABLE
>
</
TD
>
<
TD
width
="1"
bgColor
="#aaaaaa"
rowSpan
="2"
></
TD
></
TR
>
<
TR
>
<
TD
bgColor
="#aaaaaa"
height
="1"
></
TD
></
TR
></
TBODY
></
TABLE
>
<
TABLE
cellSpacing
="0"
cellPadding
="0"
width
="548"
border
="0"
>
<
TBODY
>
<
TR
>
<
TD
align
="right"
><
IMG
height
="16"
src
="TEMPLATE/TEMPLATE01/bottom.gif"
width
="244"
/></
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
<
BR
/><
BR
/>
</
TD
>
</
TR
>
</
TBODY
>
</
TABLE
>
</
BODY
></
HTML
>
<!--
保存个人信息
-->
<
span
id
="userid"
style
="visibility:hidden"
>
<
xsl:value-of
select
="Personal/UserName/Value"
/><
REMARK
>
<!--
保存当前主页的主人的用户名
-->
</
REMARK
>
</
span
>
<!--
保存个人信息
-->
<
script
language
='javascript'
type
="text/javascript"
>
showALBUM();
//用来选择显示相册中的照片
function showALBUM()
{
if(document.albumlist)
{
if(document.albumlist.albumtitle)
{
var selid=document.albumlist.albumtitle.selectedIndex;
var uid=userid.innerText;
album.src="AlbumPath/" + uid + "/" + document.albumlist.albumtitle.options[selid].value;
}
}
}
//用来打开一个新窗口来显示大图
function ShowBigPhoto()
{
var src=album.src;
if(src!="")
{
window.open(src,'_blank','width=600,height=400');
}
}
</
script
>
</
xsl:template
>
</
xsl:stylesheet
>
用xsl模板格式化xml数据的代码如下:
SqlConnection myConnection;
string UserName;
string UserID;
string idd;
StringBuilder sbXml;
string xmlName;
private
void
Page_Load(
object
sender, System.EventArgs e)
... {
myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
UserID=LoveAndFriend.pMethod.getCookie("UserID")==null?"null":(string)LoveAndFriend.pMethod.getCookie("UserID");
UserName=LoveAndFriend.pMethod.getCookie("UserName")==null?"null":(string)LoveAndFriend.pMethod.getCookie("UserName");
myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
idd=Request["idd"]==null?"":Request["idd"].ToString();
if(idd=="")
...{
Response.Write("载入信息出错,请重新登录后访问!");
Response.End();
}
xmlName="xml/" + idd + ".xml";
myConnection.Open();
if(!IsPostBack)
...{
if(File.Exists(Server.MapPath(xmlName)))
...{
ShowXml();
}
else
...{
CreateXml();
}
}
}
private
void
ShowXml()
... {
SqlCommand cm = new SqlCommand();
string strInfo="";
try
...{
cm.Connection = myConnection;
SqlDataReader dr;
string sql;
sql="select * from reg_user where username='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("载入用户信息时出错!");
}
dr.Read();
int t_id=dr["MainPage"]==null?0:Convert.ToInt32(dr["MainPage"]);
dr.Close();
if(t_id!=0)
...{
cm.CommandText="select * from personalweb where page_id=" + t_id.ToString();
}
else
...{
cm.CommandText="select * from personalweb where isDefault=1";
}
cm.CommandType=CommandType.Text;
cm.Cnotallow=myConnection;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("个人主页模板出错!");
}
dr.Read();
strInfo=dr["tmpname"]==null?"":dr["tmpname"].ToString();
if(strInfo=="")
...{
dr.Close();
throw new ArgumentException("个人主页模板出错!");
}
dr.Close();
System.Xml.XmlTextReader reader=new XmlTextReader(Server.MapPath(xmlName));
System.Xml .Xsl.XslTransform tran=new System.Xml.Xsl.XslTransform();
tran.Load(Server.MapPath (".")+"/template/" + strInfo);
XPathDocument mydata = new XPathDocument(reader);
XmlWriter writer = new XmlTextWriter(Response.OutputStream,System.Text .Encoding .Default );
tran.Transform(mydata,null,writer, null);
reader.Close();
writer.Close();
}
catch(Exception ex)
...{
LoveAndFriend.MyLeaveWord.pubFunction.AlertMessage(ex.Message);
}
finally
...{
cm.Dispose();
myConnection.Close();
myConnection.Dispose();
}
}
private
void
CreateXml()
... {
SqlCommand cm = new SqlCommand();
string strInfo="";
try
...{
cm.Connection = myConnection;
SqlDataReader dr;
sbXml=new StringBuilder();
sbXml.Append("<?xml versinotallow="1.0"?> ");
string sql;
sql="select * from reg_user where username='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("载入用户信息时出错!");
}
dr.Read();
string vNickName=dr["NickName"]==null?"":dr["NickName"].ToString();
string vBirthday=dr["Birthday"]==null?"":Convert.ToDateTime(dr["Birthday"]).Year.ToString() + "年";
string vSex=dr["Sex"]==null?"":dr["Sex"].ToString();
string vRegTime=dr["reg_datetime"]==null?"":Convert.ToDateTime(dr["reg_datetime"]).ToString("yyyy-MM-dd HH:mm");
int t_id=dr["MainPage"]==null?0:Convert.ToInt32(dr["MainPage"]);
dr.Close();
if(t_id!=0)
...{
cm.CommandText="select * from personalweb where page_id=" + t_id.ToString();
}
else
...{
cm.CommandText="select * from personalweb where isDefault=1";
}
cm.CommandType=CommandType.Text;
cm.Cnotallow=myConnection;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("个人主页模板出错!");
}
dr.Read();
strInfo=dr["tmpname"]==null?"":dr["tmpname"].ToString();
if(strInfo=="")
...{
dr.Close();
throw new ArgumentException("个人主页模板出错!");
}
sbXml.Append("<?xml-stylesheet type="text/xsl" href="Template/" + strInfo + ""?> ");
dr.Close();
sbXml.Append("<Personal> ");
AddOneElement("我的网名",vNickName,"NickName");
AddOneElement("出生年月",vBirthday,"BirthDay");
AddOneElement("注册时间",vRegTime,"RegTime");
AddOneElement("性别",vSex,"Sex");
sql="select * from v_personal where username='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
if(!dr.HasRows)
...{
dr.Close();
throw new ArgumentException("载入用户信息时出错!");
}
dr.Read();
strInfo=dr["stature"]==null?"":dr["stature"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo + "厘米";
AddOneElement("身高",strInfo,"Stature");
strInfo=dr["avoirdupois"]==null?"":dr["avoirdupois"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo + "公斤";
AddOneElement("体重",strInfo,"Avoirdupois");
strInfo=dr["bloodtype"]==null?"":dr["bloodtype"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo + "型";
AddOneElement("血型",strInfo,"BloodType");
strInfo=dr["vocation"]==null?"":dr["vocation"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("从事行业",strInfo,"Vocation");
strInfo=dr["marry"]==null?"":dr["marry"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("婚姻状况",strInfo,"Marry");
strInfo=dr["title"]==null?"":dr["title"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("职业头衔",strInfo,"Title");
strInfo=dr["income"]==null?"":dr["income"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("收入水平",strInfo,"Income");
strInfo=dr["schoolage"]==null?"":dr["schoolage"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("受教育水平",strInfo,"Schoolage");
strInfo=dr["smoke"]==null?"":dr["smoke"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("是否抽烟?",strInfo,"Smoke");
strInfo=dr["drink"]==null?"":dr["drink"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("是否喝酒?",strInfo,"Drink");
strInfo=dr["aim"]==null?"":dr["aim"].ToString();
strInfo=(strInfo=="" || strInfo=="0")?"未公布":strInfo;
AddOneElement("在寻觅",strInfo,"Aim");
strInfo=dr["character0"]==null?"":dr["character0"].ToString();
AddOneElement("自我介绍",strInfo,"MySelf");
string oCommnotallow=dr["common"]==null?"":dr["common"].ToString().Trim();
string oSport=dr["sport"]==null?"":dr["sport"].ToString().Trim();
string oSeasnotallow=dr["season"]==null?"":dr["season"].ToString().Trim();
string oFilm=dr["film"]==null?"":dr["film"].ToString().Trim();
string oMusic=dr["music"]==null?"":dr["music"].ToString().Trim();
string oMenu=dr["menu"]==null?"":dr["menu"].ToString().Trim();
string oColor=dr["color"]==null?"":dr["color"].ToString().Trim();
string oDress=dr["dress"]==null?"":dr["dress"].ToString().Trim();
string oLanguage=dr["language0"]==null?"":dr["language0"].ToString().Trim();
dr.Close();
if(oCommnotallow=="")
...{
AddOneElement("爱好","未透露","Common");
}
else
...{
sql="select * from b_common where id in (" + oCommon + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("爱好",strInfo,"Common");
}
if(oSport=="")
...{
AddOneElement("喜爱的运动","未透露","Sport");
}
else
...{
sql="select * from b_sport where id in (" + oSport + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("喜爱的运动",strInfo,"Sport");
}
if(oSeasnotallow=="")
...{
AddOneElement("钟爱的季节","未透露","Season");
}
else
...{
sql="select * from b_season where id in (" + oSeason + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("钟爱的季节",strInfo,"Season");
}
if(oFilm=="")
...{
AddOneElement("最爱的电影","未透露","Film");
}
else
...{
sql="select * from b_film where id in (" + oFilm + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("最爱的电影",strInfo,"Film");
}
if(oMusic=="")
...{
AddOneElement("倾心的音乐","未透露","Music");
}
else
...{
sql="select * from b_Music where id in (" + oMusic + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("倾心的音乐",strInfo,"Music");
}
if(oMenu=="")
...{
AddOneElement("偏好的口味","未透露","Menu");
}
else
...{
sql="select * from b_menu where id in (" + oMenu + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("偏好的口味",strInfo,"Menu");
}
if(oColor=="")
...{
AddOneElement("喜欢的颜色","未透露","Color");
}
else
...{
sql="select * from b_color where id in (" + oColor + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("喜欢的颜色",strInfo,"Color");
}
if(oDress=="")
...{
AddOneElement("日常的装扮","未透露","Dress");
}
else
...{
sql="select * from b_Dress where id in (" + oDress + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("日常的装扮",strInfo,"Dress");
}
if(oLanguage=="")
...{
AddOneElement("语言能力","未透露","Language");
}
else
...{
sql="select * from b_language where id in (" + oLanguage + ")";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
while(dr.Read())
...{
strInfo+=" " + dr["name"].ToString();
}
dr.Close();
if(strInfo=="") strInfo="未透露";
AddOneElement("语言能力",strInfo,"Language");
}
sql="select * from userlogin where username ='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
if(dr.Read())
...{
strInfo=dr["logintime"]==null?"":Convert.ToDateTime(dr["logintime"]).ToString("yyyy-MM-dd HH:mm");
AddOneElement("最近登录时间",strInfo,"LoginTime");
strInfo=dr["logincount"]==null?"":dr["logincount"].ToString();
AddOneElement("登录次数",strInfo,"LoginCount");
}
else
...{
AddOneElement("最近登录时间","","LoginTime");
strInfo=dr["logincount"]==null?"":dr["logincount"].ToString();
AddOneElement("登录次数","","LoginCount");
}
dr.Close();
sql="select * from personalPhoto where username ='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
if(dr.Read())
...{
AddOnePicLinkElement("个人形象照","ShowPhoto_p.aspx?idd=" + idd,"OriginPhoto.aspx?idd=" + idd,"SelfImg");
}
else
...{
AddOnePicLinkElement("个人形象照","images/no_photo.gif","OriginPhoto.aspx?idd=" + idd,"SelfImg");
}
dr.Close();
sql="select photo,introduce from myalbum where username ='" + idd + "'";
cm.CommandText=sql;
cm.CommandType=CommandType.Text;
dr=cm.ExecuteReader();
strInfo="";
sbXml.Append("<Album> ");
int t=0;
if(dr.HasRows)
...{
while(dr.Read())
...{
t++;
sbXml.Append("<Photo> ");
sbXml.Append("<FileName>" + dr["photo"].ToString() + "</FileName> ");
sbXml.Append("<Title>" + dr["introduce"].ToString() + "</Title> ");
sbXml.Append("</Photo> ");
}
sbXml.Append("<Count>" + t.ToString() + "</Count> ");
}
else
...{
sbXml.Append("<Count>0</Count> ");
}
sbXml.Append("</Album> ");
dr.Close();
AddOneElement("用户名",idd,"UserName");
AddOneLinkElement("联系方式","myleaveword/add.aspx?user_id=" + idd,"联系此会员","LinkMethod");
AddOneLinkElement("加入联络名单","myleaveword/AddToLinkmanList.aspx?u_id=" + idd,"加入联络名单","AddLinkman");
AddOneLinkElement("加入追求名单","myleaveword/AddToWooerList.aspx?u_id=" + idd,"加入追求名单","AddWooer");
AddOneLinkElement("心情日记","mydiary/personalpubdiary.aspx?user_id=" + idd,"浏览我的心情日记","LookDiary");
sbXml.Append("</Personal>");
if(!File.Exists(Server.MapPath(xmlName)))
...{
FileStream fs = File.Open(Server.MapPath(xmlName), FileMode.Create ,FileAccess.Write,FileShare.Write);
...{
StreamWriter writer = new StreamWriter(fs);
writer.Write(sbXml.ToString());
writer.Flush();
fs.Close();
}
}
Response.Write(sbXml.ToString());
}
catch(Exception ex)
...{
LoveAndFriend.MyLeaveWord.pubFunction.AlertMessage(ex.Message);
}
finally
...{
cm.Dispose();
myConnection.Close();
myConnection.Dispose();
}
}
void AddOneElement(
string
oName,
string
oValue,
string
oElement)
... {
sbXml.Append("<" + oElement + "> ");
sbXml.Append("<Name>" + oName + "</Name> ");
sbXml.Append("<Value>" + oValue + "</Value> ");
sbXml.Append("</" + oElement + "> ");
}
void AddOneLinkElement(
string
oName,
string
oLink,
string
oText,
string
oElement)
... {
sbXml.Append("<" + oElement + "> ");
sbXml.Append("<Name>" + oName + "</Name> ");
sbXml.Append("<Link>" + oLink + "</Link> ");
sbXml.Append("<Text>" + oText + "</Text> ");
sbXml.Append("</" + oElement + "> ");
}
void AddOnePicLinkElement(
string
oName,
string
oSrc,
string
oLink,
string
oElement)
... {
sbXml.Append("<" + oElement + "> ");
sbXml.Append("<Name>" + oName + "</Name> ");
sbXml.Append("<Src>" + oSrc + "</Src> ");
sbXml.Append("<Link>" + oLink + "</Link> ");
sbXml.Append("</" + oElement + "> ");
}
标签:...,REMARK,界面,strInfo,xsl,TD,dr,模板 From: https://blog.51cto.com/u_8215601/7507378