<items>
<item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
<item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
<item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
</item>
</items>请问怎么生成呢??其中News,Markets,Travel,Travel2006从数据库读出,又由News读出下面的 <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
<item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
<item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
</item>
<item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
<item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
<item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
</item>
</items>请问怎么生成呢??其中News,Markets,Travel,Travel2006从数据库读出,又由News读出下面的 <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
<item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
<item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
</item>
<item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
<item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
<item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
</item> <item Text="Markets" NavigateUrl="WebForm1.aspx?page=ets" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Commentary" NavigateUrl="WebForm1.aspx?page=commentary" />
<item Text="Technology" NavigateUrl="WebForm1.aspx?page=technology" />
<item Text="Personal Finance" NavigateUrl="WebForm1.aspx?page=personal_finance" />
<item Text="Mutual Funds" NavigateUrl="WebForm1.aspx?page=mutual_funds" />
</item> <item Text="Showbiz" NavigateUrl="WebForm1.aspx?page=showbiz" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Movies" NavigateUrl="WebForm1.aspx?page=movies" />
<item Text="Music" NavigateUrl="WebForm1.aspx?page=music" />
<item Text="Television" NavigateUrl="WebForm1.aspx?page=television" />
<item Text="Books" NavigateUrl="WebForm1.aspx?page=books" />
<item Text="Video | Audio" NavigateUrl="WebForm1.aspx?page=video_audio" />
</item> <item Text="Travel" NavigateUrl="WebForm1.aspx?page=travel" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Destinations" NavigateUrl="WebForm1.aspx?page=destinations" />
<item Text="Agencies" NavigateUrl="WebForm1.aspx?page=agencies" />
<item Text="Photo of the Day" NavigateUrl="WebForm1.aspx?page=photo_of_the_day" />
</item> <item Text="Travel2006" NavigateUrl="WebForm1.aspx?page=travel200" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Destinations22" NavigateUrl="WebForm1.aspx?page=destinations" />
<item Text="Agencies2006" NavigateUrl="WebForm1.aspx?page=agencies" />
<item Text="Photo of the Day2006" NavigateUrl="WebForm1.aspx?page=photo_of_the_day" />
</item>
</items>其中News,Markets,Travel,Travel2006从数据库读出,又由News读出下面的 <item Text="News" NavigateUrl="WebForm1.aspx" DefaultSubItemLookId="Level2Tab" DefaultSubItemSelectedLookId="SelectedLevel2Tab" >
<item Text="Top Stories" NavigateUrl="WebForm1.aspx?page=top_stories" />
<item Text="Breaking News" NavigateUrl="WebForm1.aspx?page=breaking_news" />
<item Text="World News" NavigateUrl="WebForm1.aspx?page=world_news" />
</item>
DataTable dt=查询的数据;//根据News,Markets,Travel,Travel2006条件判断循环的拼字符串string s="";for(int i=0;i<dt.Rows.Count;i++ )
{
if(dt.Rows[i]["new"].ToString()=="new")
{
s+="<item>+";
s+="<item Text="+News+" ... >+";
s+="...+";
s+="...+";
s+="</item>";
}
if(dt.Rows[i]["Markets"]=="Markets")
{
s+="<item>+";
s+="<item Text="+Markets+" ... >+";
s+="...+";
s+="...+";
s+="</item>";
}
...
...}//用io写xmlStreamWriter sw=new StreamWriter( Server.MapPath("")+"/"+filename+".xml",false,System.Text.Encoding.GetEncoding("GB2312"));
sw.Write(s);
sw.Close();