導入org . Apache . XML . serialize . XML serializer;
string writer string out = new string writer();
OutputFormat format =新的輸出格式(doc,“UTF-8”,true);
嘗試{
XML serializer serial = new XML serializer(string out,format);
serial . asdomserializer();
serial . serialize(doc . getdocumentelement());
} catch(例外情況){
ex . printstacktrace();
}
CString str = string out . tostring();
//doc是壹個文檔。Str是對應於doc的XML的字符串表示。