使用xmltextreader对xml进行简单的读取和写入操作[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 yeiliuxing 的 blog

使用xmltextreader对xml文件进行简单的以对象形式的读取和写入操作

baseserializeelement

-------------------------------------------------------------

using system;
using system.xml;
using system.collections;

namespace local.framework.common
{
 /// <summary>
 /// basexmlserializer 的摘要说明。
 /// --fallseir.li 20050427 15:12
 /// </summary>
 public class baseserializeelement
 {
  public baseserializeelement()
  {
  }
  public baseserializeelement(xmlreader reader,bool isroot)
  {
   this._isroot=isroot;
   readxml(reader,isroot);
  }
  public baseserializeelement(xmlreader reader):this(reader,false){}

  #region attributes
  public bool isroot
  {
   get{return _isroot;}
  }
  private bool _isroot;
  public string tag
  {
   get{return _tag;}
  }
  private string _tag;
  public string value
  {
   get{return _value;}
  }
  public string _value;
  public string cdata
  {
   get{return _cdata;}
  }
  private string _cdata;
  public arraylist elements
  {
   get{return _elements;}
  }
  private arraylist _elements;
  
  public hashtable attributes
  {
   get
   {
    return _attributes;
   }
  }
  private hashtable _attributes;

  private string _prefix;
  private string _namespaceuri;
  private string _xmllang;
  //private string _xmlspace;
        private string _baseuri;
  //private xmlnametable _nametable;

  //root
  private string _declaration;
  private string _documenttype;

  #endregion

  public void addattribute(string key,string value)
  {
   if(_attributes==null)
    _attributes=new hashtable();
   if(_attributes.containskey(key))
   {
    _attributes[key]=value;
   }
   else
   {
    _attributes.add(key,value);
   }
  }
  public void addelement(baseserializeelement element)
  {
   if(_elements==null)
    _elements=new arraylist();
   _elements.add(element);
  }

  #region ixmlserializable 成员

本文关键:使用xmltextreader对xml进行简单的读取和写入操作
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top