本文整理汇总了C#中Discuz.Common.Xml.XmlDocumentExtender.SelectNodes方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocumentExtender.SelectNodes方法的具体用法?C# XmlDocumentExtender.SelectNodes怎么用?C# XmlDocumentExtender.SelectNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discuz.Common.Xml.XmlDocumentExtender
的用法示例。
在下文中一共展示了XmlDocumentExtender.SelectNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadWebSiteConfig
/// <summary>
/// 装载WebSite信息
/// </summary>
private void LoadWebSiteConfig()
{
#region 装载主题信息
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList topiclistNode = doc.SelectNodes("/Aggregationinfo/Data/Hottopiclist/Topic");
XmlNodeList website_spacelistnode = doc.SelectNodes("/Aggregationinfo/Forum/Hottopiclist/Topic");
XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor();
XmlNodeInnerTextVisitor pagetopicvisitor = new XmlNodeInnerTextVisitor();
forumlist.Text = "";
int i = 0;
foreach (XmlNode topic in topiclistNode)
{
topicvisitor.SetNode(topic);
bool isCheck = false;
foreach (XmlNode index in website_spacelistnode)
{
pagetopicvisitor.SetNode(index);
if (topicvisitor["tid"].ToString() == pagetopicvisitor["tid"].ToString())
{
isCheck = true;
break;
}
}
forumlist.Text += "<div class='mo' id='m" + i + "' flag='f" + i + "'><h1><input type='checkbox' name='tid' " + (isCheck ? "checked" : "") + " value='" + topicvisitor["tid"] + "'>" + topicvisitor["title"] + "</h1></div>\n";
i++;
}
#endregion
}
示例2: BindData
public void BindData()
{
string menuId = DNTRequest.GetString("menuid");
string menuTitle = "";
string menuSubMenuList = "";
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu");
foreach (XmlNode menuItem in mainMenus) //查找主菜单信息
{
if (menuItem["id"].InnerText == menuId)
{
menuTitle = menuItem["title"].InnerText;
menuSubMenuList = menuItem["mainmenulist"].InnerText;
break;
}
}
DataGrid1.TableHeaderName = menuTitle + " 菜单项管理";
XmlNodeList subMenus = doc.SelectNodes("/dataset/mainmenu");
DataTable dt = new DataTable();
if (menuSubMenuList == "") //该菜单没有子菜单
{
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
return;
}
dt.Columns.Add("id");
dt.Columns.Add("menuid");
dt.Columns.Add("submenuid");
dt.Columns.Add("menutitle");
dt.Columns.Add("delitem");
foreach (XmlNode subMenuItem in subMenus)
{
if (("," + menuSubMenuList + ",").IndexOf("," + subMenuItem["id"].InnerText + ",") != -1)
{
DataRow dr = dt.NewRow();
dr["id"] = subMenuItem["id"].InnerText;
dr["menuid"] = menuId;
dr["submenuid"] = subMenuItem["menuid"].InnerText;
dr["menutitle"] = subMenuItem["menutitle"].InnerText;
if (FindSubMenuItem(subMenuItem["menuid"].InnerText,doc))
{
dr["delitem"] = "删除";
}
else
{
dr["delitem"] = "<a href='managesubmenu.aspx?mode=del&menuid=" + menuId + "&submenuid=" + subMenuItem["id"].InnerText + "' onclick='return confirm(\"您确认要删除此菜单项吗?\");'>删除</a>";
}
dt.Rows.Add(dr);
}
}
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
}
示例3: Uri
/*private void SaveManagerBody()
{
string url = Context.Request.Url.ToString().ToLower().Substring(0, Context.Request.Url.ToString().ToLower().IndexOf("rapidset")) + "framepage/managerbody.aspx";
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
req.Method = "GET";
WebResponse wr = req.GetResponse();
StreamReader sr = new StreamReader(wr.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312"));
string html = sr.ReadToEnd();
FileStream fs = new FileStream(Utils.GetMapPath("../framepage/managerbody.htm"), FileMode.Create);
byte[] bt = System.Text.Encoding.UTF8.GetBytes(html);
fs.Write(bt, 0, bt.Length);
fs.Close();
}*/
private void BindDataGrid()
{
DataGrid1.TableHeaderName = "菜单管理";
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("id"));
dt.Columns.Add(new DataColumn("title"));
dt.Columns.Add(new DataColumn("defaulturl"));
dt.Columns.Add(new DataColumn("system"));
dt.Columns.Add(new DataColumn("delitem"));
foreach (XmlNode menuitem in mainmenus)
{
DataRow dr = dt.NewRow();
dr["id"] = menuitem["id"].InnerText;
dr["title"] = menuitem["title"].InnerText;
dr["defaulturl"] = menuitem["defaulturl"].InnerText;
dr["system"] = menuitem["system"].InnerText != "0" ? "是" : "否";
if (menuitem["mainmenulist"].InnerText != "")
dr["delitem"] = "删除";
else
dr["delitem"] = "<a href='managemainmenu.aspx?mode=del&menuid=" + menuitem["id"].InnerText + "' onclick='return confirm(\"您确认要删除此菜单项吗?\")'>删除</a>";
dt.Rows.Add(dr);
}
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
}
示例4: LoadWebSiteConfig
private void LoadWebSiteConfig()
{
#region 装载个人空间信息
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList data_spacelistNode = doc.SelectNodes("/Aggregationinfo/Aggregationdata/" + pagename + "aggregationdata/" + pagename + "_spacelist/Space");
XmlNodeList index_spacelistnode = doc.SelectNodes("/Aggregationinfo/Aggregationpage/" + pagename + "/" + pagename + "_spacelist/Space");
XmlNodeInnerTextVisitor dataspacevisitor = new XmlNodeInnerTextVisitor();
XmlNodeInnerTextVisitor indexspacevisitor = new XmlNodeInnerTextVisitor();
int i = 0;
spacelist.Text = "";
foreach (XmlNode data in data_spacelistNode)
{
dataspacevisitor.SetNode(data);
bool isCheck = false;
foreach (XmlNode index in index_spacelistnode)
{
indexspacevisitor.SetNode(index);
if (dataspacevisitor["spaceid"].ToString() == indexspacevisitor["spaceid"].ToString())
{
isCheck = true;
break;
}
}
spacelist.Text += "<div class='mo' id='m" + i + "' flag='f" + i + "'><h1><input type='checkbox' name='sid' " + (isCheck ? "checked" : "") + " value='" + dataspacevisitor["spaceid"] + "'>" + dataspacevisitor["title"] + "</h1></div>\n";
i++;
}
#endregion
}
示例5: GetWebsiteConfig
private DataTable GetWebsiteConfig()
{
#region 装载主题
DataTable dt = new DataTable();
dt.Columns.Add("tid");
dt.Columns.Add("title");
dt.Columns.Add("poster");
dt.Columns.Add("postdatetime");
dt.Columns.Add("showtype");
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList topiclistNode = doc.SelectNodes("/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist/Topic");
XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor();
foreach (XmlNode topic in topiclistNode)
{
topicvisitor.SetNode(topic);
DataRow dr = dt.NewRow();
dr["tid"] = topicvisitor["topicid"];
dr["title"] = topicvisitor["title"];
dr["poster"] = topicvisitor["poster"];
dr["postdatetime"] = topicvisitor["postdatetime"];
dt.Rows.Add(dr);
}
return dt;
#endregion
}
示例6: GetParm
/// <summary>
/// 获取当前页面的参数
/// </summary>
/// <param name="doc"></param>
/// <param name="menuparentid"></param>
/// <returns></returns>
public string[] GetParm(XmlDocumentExtender doc, string menuparentid)
{
string[] parm = new string[3];
XmlNodeList mainmenus = doc.SelectNodes("/dataset/mainmenu");
XmlNodeInnerTextVisitor menuvisitor = new XmlNodeInnerTextVisitor();
foreach (XmlNode mainmenu in mainmenus)
{
menuvisitor.SetNode(mainmenu);
if (menuvisitor["menuid"] == menuparentid)
{
parm[0] = menuvisitor["id"];
break;
}
}
XmlNodeList toptabmenus = doc.SelectNodes("/dataset/toptabmenu");
foreach (XmlNode toptabmenu in toptabmenus)
{
menuvisitor.SetNode(toptabmenu);
if (("," + menuvisitor["mainmenulist"] + ",").IndexOf("," + parm[0] + ",") != -1)
{
parm[1] = menuvisitor["id"];
parm[2] = menuvisitor["mainmenulist"];
break;
}
}
return parm;
}
示例7: BindEditData
private void BindEditData(string tid)
{
#region 装载主题编辑
panel1.Visible = true;
XmlDocumentExtender doc = new XmlDocumentExtender();
if (!File.Exists(configPath))
return;
doc.Load(configPath);
string topicPath = "/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist/Topic";
if (fid != "")
topicPath = "/Aggregationinfo/Forum/Topiclist/Topic";
XmlNodeList topiclistNode = doc.SelectNodes(topicPath);
XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor();
foreach (XmlNode topic in topiclistNode)
{
topicvisitor.SetNode(topic);
if (topicvisitor["topicid"] == tid)
{
topicid.Value = topicvisitor["topicid"];
title.Text = topicvisitor["title"];
poster.Text = topicvisitor["poster"];
postdatetime.Text = topicvisitor["postdatetime"];
shortdescription.Text = topicvisitor["shortdescription"];
fulldescription.Value = topicvisitor["fulldescription"];
}
}
#endregion
}
示例8: BindDataGrid
private void BindDataGrid()
{
DataGrid1.TableHeaderName = pagename + " 子菜单项管理";
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
string submenuid = DNTRequest.GetString("submenuid");
XmlNodeList submenusitem = doc.SelectNodes("/dataset/submain");
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("id"));
dt.Columns.Add(new DataColumn("menutitle"));
dt.Columns.Add(new DataColumn("link"));
int i = 0;
foreach (XmlNode menuitem in submenusitem)
{
if(menuitem["menuparentid"].InnerText == submenuid)
{
DataRow dr = dt.NewRow();
dr["id"] = i.ToString();
dr["menutitle"] = menuitem["menutitle"].InnerText;
dr["link"] = menuitem["link"].InnerText;
dt.Rows.Add(dr);
}
i++;
}
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
}
示例9: NewMainMenu
/// <summary>
/// 增加主菜单
/// </summary>
/// <param name="title">主菜单标题</param>
/// <param name="defaulturl">主菜单默认展开的页面</param>
/// <returns>新主菜单项ID</returns>
public static int NewMainMenu(string title, string defaulturl)
{
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
int newMenuId = mainmenus.Count + 1;
XmlElement newMainMenuItem = doc.CreateElement("toptabmenu");
XmlElement node = doc.CreateElement("id");
node.InnerText = newMenuId.ToString();
newMainMenuItem.AppendChild(node);
node = doc.CreateElement("title");
node.InnerText = title;
newMainMenuItem.AppendChild(node);
node = doc.CreateElement("mainmenulist");
node.InnerText = "";
newMainMenuItem.AppendChild(node);
node = doc.CreateElement("mainmenuidlist");
node.InnerText = "";
newMainMenuItem.AppendChild(node);
node = doc.CreateElement("defaulturl");
node.InnerText = defaulturl;
newMainMenuItem.AppendChild(node);
node = doc.CreateElement("system");
node.InnerText = "0";
newMainMenuItem.AppendChild(node);
doc.SelectSingleNode("/dataset").AppendChild(newMainMenuItem);
doc.Save(configPath);
return newMenuId;
}
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
att.Columns.Add("typeid");
att.Columns.Add("typename");
att.Columns.Add("extname");
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(AppDomain.CurrentDomain.BaseDirectory + "config/myattachment.config");
XmlNodeList attachtype = doc.SelectNodes("/MyAttachmentsTypeConfigInfo/attachtypes/AttachmentType");
foreach (XmlNode node in attachtype)
{
DataRow dr = att.NewRow();
dr["typeid"] = node["TypeId"].InnerText;
dr["typename"] = node["TypeName"].InnerText;
dr["extname"] = node["ExtName"].InnerText != "" ? node["ExtName"].InnerText : "无绑定类型";
att.Rows.Add(dr);
}
dt = DatabaseProvider.GetInstance().GetAttachTypes();
string typeid = DNTRequest.GetString("typeid");
if (!Page.IsPostBack)
{
BindData();
string attlist = ""; //得到已绑定的附件列表
if (att != null)
{
foreach (DataRow dr in att.Rows)
{
attlist += dr["extname"].ToString() + ",";
}
attlist = attlist.TrimEnd(',');
}
attachextensions.AddTableData(dt);
foreach (string atttype in attlist.Split(','))
{
for (int i = 0; i < attachextensions.Items.Count; i++)
{
if (atttype == attachextensions.Items[i].Text)
{
attachextensions.Items[i].Enabled = false;
break;
}
}
}
string script = "var atttype = \r\n{";
if (att != null)
{
foreach (DataRow dr in att.Rows)
{
script += "\r\n\ttype" + dr["typeid"].ToString() + ":{typename:'" + dr["typename"].ToString() + "',extname:'" + dr["extname"].ToString() + "'},";
}
script = script.TrimEnd(',');
}
script += "\r\n};";
base.RegisterStartupScript("", "<script type='text/javascript'>\r\n" + script + "\r\n</script>");
}
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
//加入快捷操作菜单
resultmessage = "<img src='../images/existmenu.gif' style='vertical-align:middle'/> 已经收藏";
string configPath = Page.Server.MapPath("xml/navmenu.config");
string title = "";
string menuparentid = "";
string url = DNTRequest.GetString("url").ToLower();
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
//读到快捷操作菜单
XmlNodeList shortcuts = doc.SelectNodes("/dataset/shortcut");
foreach (XmlNode singleshortcut in shortcuts)
{
//如果当前链接在快捷菜单内,则返回
if (singleshortcut.SelectSingleNode("link").InnerText == url.ToLower().Trim()) return;
}
XmlNodeList submains = doc.SelectNodes("/dataset/submain");
XmlNodeInnerTextVisitor submainsvisitor = new XmlNodeInnerTextVisitor();
foreach (XmlNode submain in submains)
{
submainsvisitor.SetNode(submain);
if (submainsvisitor["link"].ToLower() == url)
{
title = submainsvisitor["menutitle"];
menuparentid = submainsvisitor["menuparentid"];
}
}
string[] parm = GetParm(doc,menuparentid);
XmlElement shortcut = doc.CreateElement("shortcut");
//将当前页面存入快捷操作菜单内
doc.AppendChildElementByNameValue(ref shortcut, "link", url);
doc.AppendChildElementByNameValue(ref shortcut, "menutitle", title);
doc.AppendChildElementByNameValue(ref shortcut, "frameid", "main");
doc.AppendChildElementByNameValue(ref shortcut, "custommenu", "true");
doc.AppendChildElementByNameValue(ref shortcut, "showmenuid", parm[0]);
doc.AppendChildElementByNameValue(ref shortcut, "toptabmenuid", parm[1]);
doc.AppendChildElementByNameValue(ref shortcut, "mainmenulist", parm[2]);
doc.SelectSingleNode("/dataset").AppendChild(shortcut);
doc.Save(configPath);
//managemainmenu.CreateMenu(Utils.GetMapPath("xml/navmenu.config"), Utils.GetMapPath("framepage") + "/navmenu.js");
MenuManage.CreateMenuJson();
}
示例12: BindDataGrid
private void BindDataGrid()
{
DataGrid1.TableHeaderName = "快捷菜单管理";
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList mainmenus = doc.SelectNodes("/dataset/mainmenu");
XmlNodeList toptabmenus = doc.SelectNodes("/dataset/toptabmenu");
string[] menuText = new string[mainmenus.Count];
for (int i = 0; i < menuText.Length; i++)
{
foreach (XmlNode topmenuitem in toptabmenus)
{
if (("," + topmenuitem["mainmenulist"].InnerText + ",").IndexOf("," + mainmenus[i].SelectSingleNode("id").InnerText + ",") != -1)
{
menuText[i] = topmenuitem["title"].InnerText + "->" + mainmenus[i].SelectSingleNode("menutitle").InnerText;
break;
}
}
}
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("id"));
dt.Columns.Add(new DataColumn("local"));
XmlNodeList shortcutmenus = doc.SelectNodes("/dataset/shortcut");
XmlNodeInnerTextVisitor shortcutmenuvisitor = new XmlNodeInnerTextVisitor();
foreach (XmlNode shortcutmenu in shortcutmenus)
{
shortcutmenuvisitor.SetNode(shortcutmenu);
DataRow dr = dt.NewRow();
dr["id"] = shortcutmenuvisitor["link"];
dr["local"] = menuText[int.Parse(shortcutmenuvisitor["showmenuid"]) - 1] + "->" + shortcutmenuvisitor["menutitle"];
dt.Rows.Add(dr);
}
if (dt.Rows.Count == 0)
{
DataRow dr = dt.NewRow();
dr["id"] = "";
dr["local"] = "(暂无收藏)";
dt.Rows.Add(dr);
}
DataGrid1.DataSource = dt;
DataGrid1.DataBind();
}
示例13: LoadInfo
private void LoadInfo()
{
string fids = "";
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
fids = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomend/fidlist").InnerText;
XmlNodeList forumrecomendtopic = doc.SelectNodes("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomendtopiclist/Website_forumrecomendtopic");
List<ForumInfo> lists = Discuz.Forum.Forums.GetForumList();
DataTable forumdata = new DataTable();
forumdata.Columns.Add("fid");
forumdata.Columns.Add("name");
forumdata.Columns.Add("tid");
forumdata.Columns.Add("title");
forumdata.Columns.Add("img");
foreach (string fid in fids.Split(','))
{
foreach (ForumInfo foruminfo in lists)
{
if (foruminfo.Fid.ToString() == fid) //在板块信息中找到当前选择的板块
{
DataRow dr = forumdata.NewRow();
dr["fid"] = fid;
dr["name"] = foruminfo.Name;
dr["tid"] = "";
dr["title"] = "";
dr["img"] = "";
forumdata.Rows.Add(dr);
break;
}
}
}
foreach (XmlNode topic in forumrecomendtopic)
{
foreach (DataRow dr in forumdata.Rows)
{
if (topic["fid"].InnerText == dr["fid"].ToString())
{
dr["tid"] = topic["tid"].InnerText;
dr["title"] = topic["title"].InnerText;
dr["img"] = topic["img"].InnerText;
break;
}
}
}
DataGrid1.TableHeaderName = "推荐版块图片选择";
DataGrid1.DataKeyField = "fid";
DataGrid1.DataSource = forumdata;
DataGrid1.DataBind();
}
示例14: DataGrid1_DeleteCommand
protected void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int row = e.Item.ItemIndex;
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList shortcutmenus = doc.SelectNodes("/dataset/shortcut");
int i = 0;
foreach (XmlNode xn in shortcutmenus)
{
if(i == row)
xn.ParentNode.RemoveChild(xn);
i++;
}
doc.Save(configPath);
MenuManage.CreateMenuJson();
base.RegisterStartupScript("delete", "<script type='text/javascript'>window.parent.LoadShortcutMenu();</script>");
BindDataGrid();
}
示例15: BindEditData
private void BindEditData(string tid)
{
#region 装载主题编辑
panel1.Visible = true;
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList topiclistNode = doc.SelectNodes("/Aggregationinfo/Forum/Hottopiclist/Topic");
XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor();
foreach (XmlNode topic in topiclistNode)
{
topicvisitor.SetNode(topic);
if (topicvisitor["tid"] == tid)
{
topicid.Value = topicvisitor["tid"];
title.Text = topicvisitor["title"];
poster.Text = topicvisitor["poster"];
postdatetime.Text = topicvisitor["postdatetime"];
}
}
#endregion
}