DODONG

博客园 首页 新随笔 联系 订阅 管理
using System;
using System.Data;
using System.Xml;

namespace WebTest
{
    
/// <summary>
    
/// operateXmlBySataSet 的摘要说明。
    
/// </summary>

    public class operateXmlBySataSet
    
{
        
public operateXmlBySataSet()
        
{
            
//
            
// TODO: 在此处添加构造函数逻辑
            
//
        }


        
GetDataSetByXml

        
#region GetDataViewByXml
        
/// <summary>
        
/// 读取Xml返回一个经排序或筛选后的DataView
        
/// </summary>
        
/// <param name="strXmlPath"></param>
        
/// <param name="strWhere">筛选条件,如:"name = 'kgdiwss'"</param>
        
/// <param name="strSort">排序条件,如:"Id desc"</param>
        
/// <returns></returns>

        public static DataView GetDataViewByXml(string strXmlPath,string strWhere,string strSort)
        
{
            
try
            
{
                DataSet ds 
= new DataSet();            
                ds.ReadXml(GetXmlFullPath(strXmlPath));            
                DataView dv 
= new DataView(ds.Tables[0]);
                
if(strSort != null)
                
{
                    dv.Sort 
= strSort;
                }

                
if(strWhere != null)
                
{
                    dv.RowFilter 
= strWhere;            
                }

                
return dv;
            }

            
catch(Exception)
            
{
                
return null;
            }

        }

        
#endregion


        
WriteXmlByDataSet        

        
UpdateXmlRow        

        
DeleteXmlRowByIndex

        
DeleteXmlRows
        
        
DeleteXmlAllRows

        
GetXmlFullPath

    }

}

posted on 2005-09-27 23:56  DODONG  阅读(627)  评论(0编辑  收藏  举报