★如何用CMarkup类读写XML文件,回答完美者我叫他★阿哥★

tibetan 2004-12-02 05:19:55
本小姐刚毕业呀,学识不多希望各位帮助。^_^偏偏需要用到个英文的注释源码,偶英文又不好,气死人!所有问问各位大哥!主要需要解释如下函数,用过的人帮我下,写下函数的用法和注意事项。^_^
-----------------阿哥-----------

CMarkup() { SetDoc( NULL ); };
CMarkup( LPCTSTR szDoc ) { SetDoc( szDoc ); };
CMarkup( const CMarkup& markup ) { *this = markup; };
void operator=( const CMarkup& markup );
virtual ~CMarkup() {};

// Navigate
bool Load( LPCTSTR szFileName );
bool SetDoc( LPCTSTR szDoc );
bool IsWellFormed();
bool FindElem( LPCTSTR szName=NULL );
bool FindChildElem( LPCTSTR szName=NULL );
bool IntoElem();
bool OutOfElem();
void ResetChildPos() ;
void ResetMainPos() ;
void ResetPos() ;
CString GetTagName() const;
CString GetChildTagName() const ;
CString GetData() const ;
CString GetChildData() const ;
CString GetAttr( LPCTSTR szAttr ) const ;
CString GetChildAttr( LPCTSTR szAttr ) const ;
CString GetAttrName( int n ) const;
bool SavePos( LPCTSTR szPosName=_T("") );
bool RestorePos( LPCTSTR szPosName=_T("") );
bool GetOffsets( int& nStart, int& nEnd ) const;
CString GetError() const { return m_csError; };

// Create
bool Save( LPCTSTR szFileName );
CString GetDoc() const ;
bool AddElem( LPCTSTR szName, LPCTSTR szData=NULL ) ;
bool InsertElem( LPCTSTR szName, LPCTSTR szData=NULL ) ;
bool AddChildElem( LPCTSTR szName, LPCTSTR szData=NULL ) ;
bool InsertChildElem( LPCTSTR szName, LPCTSTR szData=NULL ) ;
bool AddAttr( LPCTSTR szAttr, LPCTSTR szValue ) ;
bool AddChildAttr( LPCTSTR szAttr, LPCTSTR szValue ) ;
bool AddAttr( LPCTSTR szAttr, int nValue ) ;
bool AddChildAttr( LPCTSTR szAttr, int nValue ) ;
bool AddChildSubDoc( LPCTSTR szSubDoc ) ;
bool InsertChildSubDoc( LPCTSTR szSubDoc ) ;
CString GetChildSubDoc() const;

// Modify
bool RemoveElem();
bool RemoveChildElem();
bool SetAttr( LPCTSTR szAttr, LPCTSTR szValue ) ;
bool SetChildAttr( LPCTSTR szAttr, LPCTSTR szValue ) ;
bool SetAttr( LPCTSTR szAttr, int nValue ) ;
bool SetChildAttr( LPCTSTR szAttr, int nValue ) ;
bool SetData( LPCTSTR szData, int nCDATA=0 ) ;
bool SetChildData( LPCTSTR szData, int nCDATA=0 );
...全文
256 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouyong2052 2004-12-06
  • 打赏
  • 举报
回复
阿妹,没见到英文啊,都是些函数名,光这没法解释啊
nga96 2004-12-06
  • 打赏
  • 举报
回复
阿妹
CleverKingWM 2004-12-06
  • 打赏
  • 举报
回复
http://www.vckbase.com/code/viewcode.asp?id=1875
上面有示例程序
tibetan 2004-12-06
  • 打赏
  • 举报
回复
希望哪位大哥帮我把 写文件的函数解释下.谢谢了。我实在没有办法了。
effun 2004-12-03
  • 打赏
  • 举报
回复
俺的C++水平不高,不过试着帮你解释一下吧。
--------------------------------------------------
以下三行为CMarkup的三个构函数
CMarkup() { SetDoc( NULL ); }; // 构造一个空的CMarkup类
CMarkup( LPCTSTR szDoc ) { SetDoc( szDoc ); }; // 构造时向类传送一个字符串,指示要读取的XML文档所在的位置。
CMarkup( const CMarkup& markup ) { *this = markup; }; // 这个不是太清楚,好象是用一个现有的实例来构造,但生成的新类与原来的markup类使用同一块内存区域。
void operator=( const CMarkup& markup ); // 好象是等号的重载
virtual ~CMarkup() {}; // 释构函数

// 导航类的函数
bool Load( LPCTSTR szFileName ); // 载入一个现有的XML文档
bool SetDoc( LPCTSTR szDoc ); // 咦?这里看糊了,不知道和上面的函数有什么区别,好象也是载入一个现有文档,具体的区别要看代码了。
bool IsWellFormed(); // 测试当前文档是否符合XML规则,即Wellformed。
bool FindElem( LPCTSTR szName=NULL ); // 查找一个节点

--------------------------------
太累了,解释不下去了。
???2008 2004-12-03
  • 打赏
  • 举报
回复
你这个帖子应该放到C++版去啊.
C++我刚学,还不太会.
wangxt 2004-12-03
  • 打赏
  • 举报
回复
帮你顶
tibetan 2004-12-03
  • 打赏
  • 举报
回复
aboluoyuren(流浪的小虾) :讨厌,我那个CMarkup类是用C++写的,是外国人写的一个很标准的解析类。我是用不来。都没有人帮小妹。好绝望!
xiaoslong 2004-12-02
  • 打赏
  • 举报
回复
帮你顶
aboluoyuren 2004-12-02
  • 打赏
  • 举报
回复
上面的是c#的,我觉得比较麻烦!
看我vb.net写的,一目了然(虽然本人水平不高)
dim WX as new xmltextWriter("\\MyXml.xml",nothing)
WX.writestartDocument(false)'定义Standalone的属性
WX.formating=formatting.indented'缩进
WX.writestartElement("我的宣言")
WX.writestartElement("MV也#")
WX.writeAttributestring("Name","aboluo")
WX.writeElementString("简单爱","嘻嘻哈哈")
WX.writeEndElement()
WX.writeEndDocument()
WX.Close()
创建xml,显示里面的元素内容。。。
哈哈,
--------------------------------------------------------------
简单就是正确,简单就是快乐!
tibetan 2004-12-02
  • 打赏
  • 举报
回复
??什么意思?
hiying 2004-12-02
  • 打赏
  • 举报
回复
先叫哥哥

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧