本文整理汇总了C#中Discuz.Common.Xml.XmlDocumentExtender.SelectSingleNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocumentExtender.SelectSingleNode方法的具体用法?C# XmlDocumentExtender.SelectSingleNode怎么用?C# XmlDocumentExtender.SelectSingleNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discuz.Common.Xml.XmlDocumentExtender
的用法示例。
在下文中一共展示了XmlDocumentExtender.SelectSingleNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: saveinfo_Click
protected void saveinfo_Click(object sender, EventArgs e)
{
string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config");
XmlDocumentExtender doc = new XmlDocumentExtender();
if (System.IO.File.Exists(configPath))
{
if (doc.SelectSingleNode("/UserConfig/ShowInfo") == null)
{
XmlNode userconfig = doc.CreateElement("UserConfig");
doc.AppendChild(userconfig);
XmlNode showinfo = doc.CreateElement("ShowInfo");
showinfo.InnerText = showhelp.SelectedValue.ToString();
userconfig.AppendChild(showinfo);
}
else
{
XmlNode showinfo = doc.SelectSingleNode("/UserConfig/ShowInfo");
showinfo.InnerText = showhelp.SelectedValue.ToString();
}
}
else
{
XmlElement userconfig = doc.CreateElement("UserConfig");
XmlElement showinfo = doc.CreateElement("ShowInfo");
showinfo.InnerText = showhelp.SelectedValue.ToString();
userconfig.AppendChild(showinfo);
doc.AppendChild(userconfig);
}
doc.Save(configPath);
this.RegisterStartupScript("PAGE", "window.location='likesetting.aspx'");
}
示例2: BindData
public void BindData()
{
#region 绑定数据
DataGrid1.AllowCustomPaging = false;
DataGrid1.DataKeyField = "menuid";
DataGrid1.TableHeaderName = "我的菜单列表";
DataSet dsSrc = new DataSet();
XmlDocumentExtender xmldocument = new XmlDocumentExtender();
xmldocument.Load(configPath);
XmlNode node = xmldocument.SelectSingleNode("/menuset");
if (node == null ||node.ChildNodes.Count == 0)
return;
XmlNodeReader rdr = new XmlNodeReader(node);
dsSrc.ReadXml(rdr);
dsSrc.Tables[0].Columns.Add("menuid");
int i = 0;
foreach (DataRow dr in dsSrc.Tables[0].Rows)
{
dr["menuid"] = i.ToString();
i++;
}
DataGrid1.DataSource = dsSrc.Tables[0];
DataGrid1.DataBind();
#endregion
}
示例3: BindData
public void BindData()
{
#region 绑定轮换图片列表
DataGrid1.AllowCustomPaging = false;
DataGrid1.DataKeyField = "rotatepicid";
DataGrid1.TableHeaderName = "聚合轮换图片列表";
XmlDocumentExtender xmldocument = new XmlDocumentExtender();
xmldocument.Load(configPath);
XmlNode node = xmldocument.SelectSingleNode(targetNode);
if (node == null || node.ChildNodes.Count == 0)
{
DataGrid1.Visible = SaveRotatepic.Visible = false;
return;
}
XmlNodeReader rdr = new XmlNodeReader(node);
dsSrc.ReadXml(rdr);
dsSrc.Tables[0].Columns.Add("rowid");
int i = 0;
foreach (DataRow dr in dsSrc.Tables[0].Rows)
{
dr["rowid"] = i.ToString();
i++;
}
DataGrid1.DataSource = dsSrc.Tables[0];
DataGrid1.DataBind();
#endregion
}
示例4: 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;
}
示例5: LoadInfo
private void LoadInfo()
{
string fids = "";
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNode fidlist = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Website_forumrecomend/fidlist");
if (fidlist == null)
{
return;
}
fids = fidlist.InnerText;
string strJson = "";
Discuz.Common.Generic.List<ForumInfo> lists = Discuz.Forum.Forums.GetForumList();
foreach (string fid in fids.Split(','))
{
foreach (ForumInfo foruminfo in lists)
{
if (foruminfo.Fid.ToString() == fid)
{
strJson += "{'fid':'" + foruminfo.Fid + "','forumtitle':'" + foruminfo.Name + "'},";
break;
}
}
}
if (strJson != "")
{
strJson = strJson.TrimEnd(',');
}
strJson = "<script type='text/javascript'>\r\nvar fidlist = [" + strJson + "];\r\nfor(var i = 0 ; i < fidlist.length ; i++)\r\n{\r\nvar no = new Option();\r\nno.value = fidlist[i]['fid'];\r\nno.text = fidlist[i]['forumtitle'];\r\nForm1.list2.options[Form1.list2.options.length] = no;\r\n}\r\n</script>";
base.RegisterStartupScript("", strJson);
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// 在此处放置用户代码以初始化页面
allowUserGroup.Attributes.Add("onclick", "ChanageUserGroupStatus(this.checked)");
if (!IsPostBack)
{
EnableSpace.SelectedValue = config.Enablespace.ToString();
EnableSpace.Items[0].Attributes.Add("onclick", "ShowHiddenOption(true);");
EnableSpace.Items[1].Attributes.Add("onclick", "ShowHiddenOption(false);");
ShowSpaceOption.Attributes.Add("style", config.Enablespace == 1 ? "display:block" : "display:none");
ShowUserGroup.Attributes.Add("style", config.Enablespace == 1 ? "display:block" : "display:none");
LoadUserGroup();
XmlDocumentExtender xmlDoc = new XmlDocumentExtender();
xmlDoc.Load(Server.MapPath("../../config/space.config"));
XmlNode root = xmlDoc.SelectSingleNode("SpaceActiveConfigInfo");
XmlNodeInnerTextVisitor rootvisitor = new XmlNodeInnerTextVisitor();
rootvisitor.SetNode(root);
allowPostcount.Checked = rootvisitor["AllowPostcount"] == "1" ? true : false;
Postcount.Text = rootvisitor["Postcount"];
allowDigestcount.Checked = rootvisitor["AllowDigestcount"] == "1" ? true : false;
Digestcount.Text = rootvisitor["Digestcount"];
allowScore.Checked = rootvisitor["AllowScore"] == "1" ? true : false;
Score.Text = rootvisitor["Score"];
allowUserGroup.Checked = rootvisitor["AllowUsergroups"] == "1" ? true : false;
string groupList = rootvisitor["Usergroups"];
if (!allowUserGroup.Checked || groupList == "")
return;
else
BindUserGroup(groupList);
ActiveType.SelectedValue = rootvisitor["ActiveType"];
BindUserGorupMaxspaceattachsize();
}
}
示例7: addmenu_Click
private void addmenu_Click(Object sender, EventArgs e)
{
#region 插入菜单
if ((atext.Text.Trim() != "") && (ahref.Text.Trim() != ""))
{
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
int lastmenuorder = 0;
if (doc.SelectSingleNode("/menuset").ChildNodes.Count != 0)
{
lastmenuorder = int.Parse(doc.SelectSingleNode("/menuset").LastChild["menuorder"].InnerText);
}
lastmenuorder++;
XmlElement menunode = doc.CreateElement("menuitem");
doc.AppendChildElementByNameValue(ref menunode, "menuorder", lastmenuorder.ToString());
doc.AppendChildElementByNameValue(ref menunode, "text", atext.Text.Trim());
doc.AppendChildElementByNameValue(ref menunode, "href", ahref.Text.Trim());
doc.AppendChildElementByNameValue(ref menunode, "onclick", aonclick.Text.Trim(),true);
doc.AppendChildElementByNameValue(ref menunode, "target", atarget.Text.Trim());
doc.CreateNode("/menuset").AppendChild(menunode);
doc.Save(configPath);
CreateJsFile();
try
{
BindData();
ResetForm();
base.RegisterStartupScript("PAGE", "window.location.href='forum_mymenumanage.aspx';");
return;
}
catch
{
base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='forum_mymenumanage.aspx';</script>");
return;
}
}
else
{
base.RegisterStartupScript("", "<script>alert('链接文字和链接地址是必须输入的,如果无链接地址请输入\"#\".');window.location.href='forum_mymenumanage.aspx';</script>");
return;
}
#endregion
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config");
if (!IsPostBack)
{
if (File.Exists(configPath))
{
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
showhelp.SelectedValue = doc.SelectSingleNode("/UserConfig/ShowInfo") != null ? doc.SelectSingleNode("/UserConfig/ShowInfo").InnerText : "1";
showupgrade.SelectedValue = doc.SelectSingleNode("/UserConfig/ShowUpgrade") != null ? doc.SelectSingleNode("/UserConfig/ShowUpgrade").InnerText : "1";
}
else
{
showhelp.SelectedValue = "1";
showupgrade.SelectedValue = "1";
}
}
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
bool isShowUpgradeInfo = false;
string configPath = Page.Server.MapPath("../xml/user_" + this.userid + ".config");
if (File.Exists(configPath))
{
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
isShowUpgradeInfo = doc.SelectSingleNode("/UserConfig/ShowUpgrade") != null ? doc.SelectSingleNode("/UserConfig/ShowUpgrade").InnerText == "1": false;
}
else
isShowUpgradeInfo = true;
if(isShowUpgradeInfo)
LoadUpgradeInfo();
LoadTemplateInfo();
GetStatInfo();
//加载论坛版块信息
forumid.BuildTree(Forums.GetForumListForDataTable(), "name", "fid");
LinkDiscuzVersionPage();
}
示例10: 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();
}
示例11: LoadWebSiteConfig
private void LoadWebSiteConfig()
{
#region 绑定自动推荐相册
//装载配置文件
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNode albumconfig = doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Albumindex/Albumconfig");
focusphotoshowtype.SelectedIndex = Convert.ToInt32(doc.GetSingleNodeValue(albumconfig, "Focusphotoshowtype"));
focusphotodays.Text = doc.GetSingleNodeValue(albumconfig, "Focusphotodays");
focusphotocount.Text = doc.GetSingleNodeValue(albumconfig, "Focusphotocount");
recommendalbumtype.SelectedIndex = Convert.ToInt32(doc.GetSingleNodeValue(albumconfig, "Focusalbumshowtype"));
focusalbumdays.Text = doc.GetSingleNodeValue(albumconfig, "Focusalbumdays");
focusalbumcount.Text = doc.GetSingleNodeValue(albumconfig, "Focusalbumcount");
weekhot.Text = doc.GetSingleNodeValue(albumconfig, "Weekhot");
#endregion
}
示例12: 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();
}
示例13: NewSubMenu
/// <summary>
/// 增加子菜单
/// </summary>
/// <param name="mainmenuid">主菜单ID</param>
/// <param name="menutitle">子菜单标题</param>
/// <returns>新建子菜单ID</returns>
public static int NewSubMenu(int mainmenuid, string menutitle)
{
int newid = 1;
int newmenuid = 100;
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
newid += int.Parse(submains.Item(submains.Count - 1)["id"].InnerText);
newmenuid += int.Parse(submains.Item(submains.Count - 1)["menuid"].InnerText);
XmlElement mainmenu = doc.CreateElement("mainmenu");
XmlElement node = doc.CreateElement("id");
node.InnerText = newid.ToString();
mainmenu.AppendChild(node);
node = doc.CreateElement("menuid");
node.InnerText = newmenuid.ToString();
mainmenu.AppendChild(node);
node = doc.CreateElement("menutitle");
node.InnerText = menutitle;
mainmenu.AppendChild(node);
doc.SelectSingleNode("/dataset").AppendChild(mainmenu);
XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu");
foreach (XmlNode menuItem in mainMenus) //查找主菜单信息
{
if (menuItem["id"].InnerText == mainmenuid.ToString())
{
menuItem["mainmenulist"].InnerText += "," + newid;
menuItem["mainmenuidlist"].InnerText += "," + newmenuid;
menuItem["mainmenulist"].InnerText = menuItem["mainmenulist"].InnerText.TrimStart(',');
menuItem["mainmenuidlist"].InnerText = menuItem["mainmenuidlist"].InnerText.TrimStart(',');
break;
}
}
doc.Save(configPath);
return newmenuid;
}
示例14: SaveTopicDisplay_Click
/// <summary>
/// 保存主题显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void SaveTopicDisplay_Click(object sender, EventArgs e)
{
#region 保存主题显示
//if (!Utils.IsNumeric(topnumber.Text))
//{
// base.RegisterStartupScript("", "<script>alert('显示主题条数必须为数字!');</script>");
// return;
//}
//if (Convert.ToInt32(topnumber.Text) <= 0)
//{
// base.RegisterStartupScript("", "<script>alert('显示主题条数至少是1条!');</script>");
// return;
//}
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
doc.RemoveNodeAndChildNode("/Aggregationinfo/Aggregationpage/Website/Forum/Bbs");
//doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum");
if (doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum") == null)
doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum");
XmlElement BBS = doc.CreateElement("Bbs");
doc.AppendChildElementByNameValue(ref BBS, "Topnumber", topnumber.Text, false);
doc.AppendChildElementByNameValue(ref BBS, "Showtype", showtype.SelectedValue, false);
doc.SelectSingleNode("/Aggregationinfo/Aggregationpage/Website/Forum").AppendChild(BBS);
doc.Save(configPath);
AggregationConfig.ResetConfig();
AggregationFacade.ForumAggregation.ClearAllDataBind();
#endregion
}
示例15: SaveRotatepic_Click
private void SaveRotatepic_Click(object sender, EventArgs e)
{
#region 保存轮换图片修改
int rowid = 0;
bool error = false;
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
XmlNodeList __xmlnodelist = doc.SelectSingleNode(targetNode).ChildNodes;
if ((__xmlnodelist != null) && (__xmlnodelist.Count > 0))
{
doc.InitializeNode(targetNode);
}
foreach (object o in DataGrid1.GetKeyIDArray())
{
#region 轮换图片
string rotatepicid = DataGrid1.GetControlValue(rowid, "rotatepicid");
//string name = ((TextBox)E.Item.FindControl("rotatepicid")).Text;
string img = DataGrid1.GetControlValue(rowid, "img");
string url = DataGrid1.GetControlValue(rowid, "url");
string titlecontent = DataGrid1.GetControlValue(rowid, "titlecontent").Trim();
if (!Utils.IsNumeric(rotatepicid) || !Utils.IsURL(img) || !Utils.IsURL(url) || titlecontent == "")
{
//base.RegisterStartupScript("", "<script>alert('序号、图片路径或点击链接可能是非法URL或说明文字为空');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
//return;
error = true;
//continue;
break;//如果用continue,则导致正确的设置可以被保存,有错误的设置却被删除,即使被修改之前是正确的。会丢失数据
}
bool insert = false;
XmlElement rotatepicNode = doc.CreateElement(nodeName);
doc.AppendChildElementByNameValue(ref rotatepicNode, "rotatepicid", rotatepicid);
doc.AppendChildElementByNameValue(ref rotatepicNode, "pagetype", "1");
doc.AppendChildElementByNameValue(ref rotatepicNode, "img", img);
doc.AppendChildElementByNameValue(ref rotatepicNode, "url", url);
doc.AppendChildElementByNameValue(ref rotatepicNode, "titlecontent", titlecontent);
foreach (XmlNode __node in __xmlnodelist)
{
if (int.Parse(__node["rotatepicid"].InnerText) > int.Parse(rotatepicid))
{
doc.SelectSingleNode(targetNode).InsertBefore(rotatepicNode, __node);
insert = true;
break;
}
}
if (!insert)
{
doc.SelectSingleNode(targetNode).AppendChild(rotatepicNode);
}
rowid++;
#endregion
}
AggregationFacade.BaseAggregation.ClearAllDataBind();
if(!error)
{
SiteUrls.SetInstance();
AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "聚合页面论坛广告编辑", "");
doc.Save(configPath);
base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';");
return;
}
else
{
base.RegisterStartupScript("", "<script>alert('某行序号、图片路径或点击链接可能是非法URL或说明文字为空,不能进行更新.');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
return;
}
#endregion
}