本文整理汇总了C#中Discuz.Common.Xml.XmlDocumentExtender.CreateNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocumentExtender.CreateNode方法的具体用法?C# XmlDocumentExtender.CreateNode怎么用?C# XmlDocumentExtender.CreateNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discuz.Common.Xml.XmlDocumentExtender
的用法示例。
在下文中一共展示了XmlDocumentExtender.CreateNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addrota_Click
private void addrota_Click(Object sender, EventArgs e)
{
#region 插入聚合页图版轮换广告
if ((rotaimg.Text.Trim() != "") && (url.Text.Trim() != "") && (titlecontent.Text.Trim() != ""))
{
if((!Utils.IsURL(rotaimg.Text.Trim()) || (!Utils.IsURL(url.Text.Trim()))))
{
base.RegisterStartupScript("", "<script>alert('图片路径或点击链接可能是非法URL');</script>");
BindData();
ResetForm();
return;
}
XmlDocumentExtender doc = new XmlDocumentExtender();
doc.Load(configPath);
int lastRotatepicid = 0;
if (doc.SelectSingleNode(targetNode) != null)
{
if (doc.SelectSingleNode(targetNode).InnerText != "")
{
lastRotatepicid = int.Parse(doc.SelectSingleNode(targetNode).LastChild["rotatepicid"].InnerText);
}
}
lastRotatepicid++;
XmlElement rotatepicNode = doc.CreateElement(nodeName);
doc.AppendChildElementByNameValue(ref rotatepicNode, "rotatepicid", lastRotatepicid.ToString());
doc.AppendChildElementByNameValue(ref rotatepicNode, "pagetype", "1");
doc.AppendChildElementByNameValue(ref rotatepicNode, "img", rotaimg.Text.Trim());
doc.AppendChildElementByNameValue(ref rotatepicNode, "url", url.Text.Trim());
doc.AppendChildElementByNameValue(ref rotatepicNode, "titlecontent", titlecontent.Text.Trim());
doc.CreateNode(targetNode).AppendChild(rotatepicNode);
doc.Save(configPath);
AggregationFacade.BaseAggregation.ClearAllDataBind();
AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加聚合页图版轮换广告", "添加聚合页图版轮换广告,名称为: " + titlecontent.Text.Trim());
try
{
BindData();
Discuz.Cache.DNTCache.GetCacheService().RemoveObject("/Forum/ForumLinkList");
ResetForm();
base.RegisterStartupScript("PAGE", "window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';");
return;
}
catch
{
base.RegisterStartupScript("", "<script>alert('无法更新XML文件');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
return;
}
}
else
{
base.RegisterStartupScript("", "<script>alert('图片或链接地址以及标题不能为空.');window.location.href='aggregation_rotatepic.aspx?pagename=" + DNTRequest.GetString("pagename") + "';</script>");
return;
}
#endregion
}
示例2: 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
}