Asp.Net XML操作基类
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Text;
using MSXML2;
namespace EC
{
/// <summary>
/// XML 操作基类
/// </summary>
public class XmlObject : IDisposable
{
//以下为单一功能的静态类
#region 读取XML到DataSet
/**************************************************
* 函数名称:GetXml(string XmlPath)
* 功能说明:读取XML到DataSet
* 参 数:XmlPath:xml文档路径
* 使用示列:
* using EC; //引用命名空间
* string xmlPath = Server.MapPath("/EBDnsConfig/DnsConfig.xml"); //获取xml路径
* DataSet ds = EC.XmlObject.GetXml(xmlPath); //读取xml到DataSet中
************************************************/
/// <summary>
/// 功能:读取XML到DataSet中
/// </summary>
/// <param name="XmlPath">xml路径</param>
/// <returns>DataSet</returns>
public static DataSet GetXml(string XmlPath)
{
DataSet ds = new DataSet();
ds.ReadXml(@XmlPath);
return ds;
}
#endregion
#region 读取xml文档并返回一个节点
/**************************************************
* 函数名称:ReadXmlReturnNode(string XmlPath,string Node)
* 功能说明:读取xml文档并返回一个节点:适用于一级节点
* 参 数: XmlPath:xml文档路径;Node 返回的节点名称
* 适应用Xml:<?xml version="1.0" encoding="utf-8" ?>
* <root>
* <dns1>ns1.everdns.com</dns1>
* </root>
* 使用示列:
相关文档:
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString( ......
问:为什么session在有些机器上偶尔会丢失?
答:可能和机器的环境有关系,比如:防火墙或者杀毒软件等,尝试关闭防火墙。
问:为什么当调用session.abandon时并没有激发session_end方法?
答:首先session_end方法只支持inproc(进程内的)类型的session。其次要激发session_en ......
String.IndexOf 方法 (value, [startIndex], [count])
报告指定字符在此实例中的第一个匹配项的索引。搜索从指定字符位置开始,并检查指定数量的字符位置。
参数
value
要查找的 Unicode 字符。 对 value 的搜索区分大小写。
startIndex(Int32)
可选项,搜索起始位置。不设置则从0开始。
......
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
&nb ......