c#生成站點(diǎn)地圖(SiteMapPath)文件示例程序
//創(chuàng)建站點(diǎn)地圖
private void CreateSiteMap(DataSet ds)
{
XmlDeclaration declareation;
declareation = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
xmlDoc.AppendChild(declareation);
XmlElement xeRoot = xmlDoc.CreateElement("siteMap");
xmlDoc.AppendChild(xeRoot);
XmlElement xroot = xmlDoc.CreateElement("siteMapNode");
xroot.SetAttribute("title", "");
xroot.SetAttribute("url", "#");
xeRoot.AppendChild(xroot);
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
DataRowView row = ds.Tables[0].DefaultView[i];
string MainMenu = row["MainMenu"].ToString();
string NavigateUrl = row["NavigateUrl"].ToString();
if (MainMenu != str)
{
XmlElement siteMapNode = xmlDoc.CreateElement("siteMapNode");
siteMapNode.SetAttribute("title", MainMenu);
siteMapNode.SetAttribute("description", "");
siteMapNode.SetAttribute("url", NavigateUrl);
xroot.AppendChild(siteMapNode);
str = AddChildNode(MainMenu);
}
}
xmlDoc.Save(Server.MapPath("\\Web.sitemap"));
}
//添加子節(jié)點(diǎn)
private string AddChildNode(String text)
{
string sql = "select * from Menu Where MainMenu ='" + text + "'";
DataSql data = new DataSql();
data.DataCon();
DataSet ds = data.GetDataset(sql);
XmlNode root = xmlDoc.SelectSingleNode("/siteMap/siteMapNode/siteMapNode[@title='" + text + "']");
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
DataRowView row = ds.Tables[0].DefaultView[i];
string ChildMenu = row["ChildMenu"].ToString();
if (ChildMenu != "")
{
string NavigateUrl = row["NavigateUrl"].ToString();
XmlElement siteMapNode = xmlDoc.CreateElement("siteMapNode");
siteMapNode.SetAttribute("title", ChildMenu);
siteMapNode.SetAttribute("description", "");
siteMapNode.SetAttribute("url", NavigateUrl);
root.AppendChild(siteMapNode);
}
}
return text;
}
相關(guān)文章
C#基于正則表達(dá)式實(shí)現(xiàn)獲取網(wǎng)頁中所有信息的網(wǎng)頁抓取類實(shí)例
這篇文章主要介紹了C#基于正則表達(dá)式實(shí)現(xiàn)獲取網(wǎng)頁中所有信息的網(wǎng)頁抓取類,結(jié)合完整實(shí)例形式分析了C#正則網(wǎng)頁抓取類與使用技巧,需要的朋友可以參考下2017-05-05C#實(shí)現(xiàn)自定義ListBox背景的示例詳解
這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)自定義ListBox背景,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)C#有一定的幫助,感興趣的小伙伴可以跟隨小編一起了解一下2022-12-12Unity?百度AI實(shí)現(xiàn)Logo商標(biāo)識別
本文主要介紹了Unity實(shí)現(xiàn)檢測和識別圖片中的品牌LOGO信息。即對于輸入的一張圖片(可正常解碼,且長寬比適宜),輸出圖片中LOGO的名稱、位置和置信度。需要的可以參考一下2022-01-01