-
阅读(550) 评论(0) [2012-3-6]
按条件删除 item标签private string path = HttpContext.Current.Server.MapPath("~/XMLNews.xml");
XmlDocument xmldoc = new XmlDocument();private void DelXml(){xmldoc.Load(path);
XmlNodeList root = xmldoc.SelectSingleNode("//website/nav[@id='6']").ChildNodes;foreach (XmlNode node in root)
{
XmlElement Element = (XmlElement)node;
if (Element.GetAttribute("id") == "634666497935355046")
{
node.ParentNode.RemoveChild(node);
}
}阅读全文>>
-
阅读(463) 评论(0) [2012-3-6]
private string path = HttpContext.Current.Server.MapPath("~/XMLNews.xml");
XmlDocument xmldoc = new XmlDocument();修改节点private void UpdateXml(string nav_id, string news_id)
{
xmldoc.Load(path);
XmlNode root = xmldoc.SelectSingleNode("//website/nav[@id='" + news_id + "']/item[@id='" + news_id + "']");//查找需要修改的节点
XmlElement Element = (XmlElement)root;
Element.ChildNodes[0].InnerXml = "<![CDATA[我是新标题]]>";
Element.ChildNodes[1].InnerX阅读全文>>
-
阅读(530) 评论(0) [2012-3-6]
/// <summary>
/// 获取列表信息
/// </summary>
/// <param name="AttrName">分类名称</param>
/// <returns>XmlNodeList</returns>
public XmlNodeList GetData(string AttrName)
{
xmldoc.Load(path);
XmlNodeList nodelist = xmldoc.SelectNodes("//website/nav[@name='" + AttrName + "']/item");//查找nav节点 属性为AttrName 下的全部item节点
return nodelist;
}
阅读全文>>
-
阅读(530) 评论(0) [2012-3-6]
private string path = HttpContext.Current.Server.MapPath("~/XMLNews.xml");
XmlDocument xmldoc = new XmlDocument();添加节点 itemprivate void InserXml(string nav_id)
{
xmldoc.Load(path);
XmlNode root = xmldoc.SelectSingleNode("//website/nav[@id='" + nav_id + "']");
XmlElement Element = xmldoc.CreateElement("item");
Element.SetAttribute("id", DateTime.Now.Ticks.ToString());XmlElement Element_title = xmldoc.CreateElement("title");
Element_title.阅读全文>>
-
阅读(1004) 评论(0) [2012-1-6]
WebClient OpenRead 读取网页乱码问题决绝方法System.Net.WebClient wc = new System.Net.WebClient();
StreamReader sr = new StreamReader(wc.OpenRead("http://www.52hudie.com"), System.Text.Encoding.GetEncoding("utf-8"));//此处一定要与被抓去的网页的<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 保持一致 否则或导致乱码
StreamWriter sw = new StreamWriter(Server.MapPath("~/index.html"), false, System.Text.Encoding.UTF8);
string temp = sr.ReadToEnd();
Response阅读全文>>
-
阅读(1155) 评论(0) [2011-12-21]
public static void DataSetToExcel(DataSet ds, string FileName)
{//Web页面定义
HttpResponse resp;
resp = HttpContext.Current.Response;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
resp.AppendHeader("Content-disposition", "attachment;filename=" + FileName + ".xls");
resp.ContentType = "application/ms-excel";
//变量定义
string colHeaders = null;
string Is_item = null;
StringWriter sfw = new StringWriter();
//定义表对象与行对象,同时用DataSet对阅读全文>>
-
阅读(1157) 评论(0) [2011-12-6]
下载URLRewriter.dll 并引用到项目bin下一<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\d{1,6})\.lhtml</LookFor>
<SendTo>~/New_content.aspx?Bid=$1</SendTo>
</RewriterRule></Rules>
</RewriterConfig>二<httpModules><add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<a阅读全文>>
-
阅读(921) 评论(0) [2011-12-6]
在web.config中使用身份模拟,在<system.web>节中加入 <identity impersonate="true" userName="你的用户名" password="密码"/>
</system.web>
阅读全文>>