symbian 创建 xml
2010-07-21 04:24:00 来源:WEB开发网RFile file;
//生成XML文件
if (KErrNone != file.Open(aFs, _L("c:\data\MarkXML"), EFileWrite))
file.Replace(aFs, _L("c:\data\MarkXML"), EFileWrite);
//设置XML编码格式
//可以生成unicode和ascall格式的XML
HBufC8* xml = Root->AsXmlL();
if(xml)
file.Write(xml->Des());
file.Close();
delete xml;
delete pSenDomFragment;
delete Root;
//生成XML的土方法
TBuf8 <128> startBuf;
startBuf.Append(_L8(""));
startBuf.Append(_L8("
//xml trail
TBuf8 <32> endBuf;
endBuf.Append(_L8(" "));
_LIT8(KTypeFormat,"
_LIT8(KTrueNameFormat,"
bufType.AppendFormat(KTypeFormat,iType);
////get name
bufTrueName.AppendFormat(KTrueNameFormat,&bufName);
//生成XML头
err = file.Write(startBuf);
err = file.Write(_L8(" "));
//生成XML数据
err = file.Write(bufType);
err = file.Write(_L8(" "));
err = file.Write(bufName);
//生成XML文件尾
err = file.Write(endBuf);
以上代码在N95上测试通过
更多精彩
赞助商链接