Symbian (Generate XML CSenDomFragment)处理XML的方法
2010-02-03 16:27:00 来源:WEB开发网//生成XML文件
if (KErrNone != file.Open(aFs, _L("c:dataMarkXML"), EFileWrite))
file.Replace(aFs, _L("c:dataMarkXML"), 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上测试通过
更多精彩
赞助商链接