Xerces C 更新XML文件的空行格式問題

2021-09-30 09:09:27 字數 904 閱讀 3956

使用xml

大致**如下:

xmlch tempstr[100];

xmlstring::transcode("ls", tempstr, 99);

domimplementation *impl          = domimplementationregistry::getdomimplementation(tempstr);

domwriter         *theserializer = ((domimplementationls*)impl)->createdomwriter();

//設定輸出格式為美觀化

if (theserializer->cansetfeature(xmluni::fgdomwrtformatprettyprint, true))

theserializer->setfeature(xmluni::fgdomwrtformatprettyprint, true);

...xmlformattarget *myformtarget = new localfileformattarget(strfilename.c_str());

// do the serialization through domwriter::writenode();

//theserializer->writenode(myformtarget, *doc);

這種方法輸出的xml文件,每更新一次xml檔案,就會在xml文件中每個元素節點後增加乙個空行,這樣更新的次數越多,xml檔案中的空行越多,檔案就變得越來越大。如果把不設定xmluni::fgdomwrtformatprettyprint,就不會出現檔案增加空行的情況,但生成的xml檔案可讀性比較差。

檢視了xerces-c++的文件及其例子,好象沒有其它更好的方法解決。希望有使用過xerces-c++的朋友來指點一下!

利用Xerces c庫解析XML

如下是乙個xml檔案 sample.xml 常用xml解析庫 庫1 xerces c 庫2 libxml2 庫3 expat 庫4 tinyxml 庫5 msxml include include include include include include include include inc...

使用xerces c 庫編寫XSD校驗XML的類

由於需要寫個xsd來校驗xml功能的類,上網搜尋了很多資料,都不能完全滿足需要,於是在多方參考了網路上的文章後,自己進一步改進了一下。直接貼 備忘。標頭檔案 ixmlvalidation.h ifndef ixml validation h define ixml validation h incl...

Xml文件的解析

1.首先自定義乙個xml文字檔案 1天下無雙 1202 流星錘150 3無敵霸王龍 2002.再自定義乙個類 using system using system.collections.generic using system.linq using system.text using system....