這幾年寫程式養成一個習慣,只要讀外部設定檔,都會用XML
有一個原因是因為使用的遊戲引擎,提供了一個工具,讀寫XML都非常的方便
前不久,在寫一個工具軟體的時候,有需要讀取XML,但是我發現沒有使用上面講到的工具
要去讀寫XML是一件很麻煩的事
我一直秉持"別人的Code會更好!"這個概念,於是我就上網去找open source
找讀寫XML的程式,我找到了
一個工具叫"tinyxml"
他算是還蠻方便的工具,但是真的在使用上,比上面講到的工具,麻煩100倍吧....
TiXmlDocument doc;
if (doc.LoadFile(replaceXML.GetString()))
{
TiXmlElement *RootElement = doc.RootElement();
TiXmlElement *Element = RootElement->FirstChildElement(_T("PatchPacket"));
TiXmlElement *UnitElement = NULL;
UnitElement = new TiXmlElement("Unit");
Element->LinkEndChild(UnitElement);
VersionElement = new TiXmlElement("Version");
UnitElement->LinkEndChild(VersionElement);
textContent = new TiXmlText(fileListPatchVer);
VersionElement->LinkEndChild(textContent);
....
(這是一個不完整的code,請不要拿去用~_~)
上面這段code大概是希望產生一個
<root>
<PatchPacket>
<Unit>
<Version>0.3.0.1</Version>
</Unit>
</PatchPacket>
</root>
這樣的一個xml
如果使用一開始講到的工具
data = ResMgr.openSection(XMLFile)
data.writeString("PatchPacket/Unit/Virsion",0.3.0.1)
就醬....
光是看行數就知道差很多了,使用tinyxml,你自己必須產生相對應的class來作操作
而相對的,這個工具只需要打入路徑,就可以作操作了
雖然較簡單的操作機制,但是效能上差別多少我就不敢保證了
不過使用上的確是能減少很多開發時間就是了...
不過我一直提到的工具是某引擎內建的工具...我自己開發時,是不能使用的...
所以我就自己寫了一個
XML Reader ----- IPaXMLSection
除了IPaEngine可以使用以外,以後如果有需要讀寫XML也不用怕了~
我是想要open source
但是google code,我不會用~_~
又懶的找網路空間,有興趣的人在跟我要吧~:)
<PatchPacket>
<Unit>
<Version>0.3.0.1</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.1.patch.pck</File>
<Size>13203141</Size>
</Unit>
<Unit>
<Version>0.3.0.2</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.2.patch.pck</File>
<Size>346692</Size>
</Unit>
<Unit>
<Version>0.3.0.3</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.3.patch.pck</File>
<Size>517388</Size>
</Unit>
<Unit>
<Version>0.3.0.4</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.4.patch.pck</File>
<Size>930080</Size>
</Unit>
<Unit>
<Version>0.3.0.5</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.5.patch.pck</File>
<Size>4880895</Size>
</Unit>
<Unit>
<Version>0.3.0.6</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.6.patch.pck</File>
<Size>36968430</Size>
</Unit>
<Unit>
<Version>0.3.0.7</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.7.patch.pck</File>
<Size>9463124</Size>
</Unit>
<Unit>
<Version>0.3.0.8</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.8.patch.pck</File>
<Size>11803361</Size>
</Unit>
<Unit>
<Version>0.3.0.9</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.0.9.patch.pck</File>
<Size>1205144</Size>
</Unit>
<Unit>
<Version>0.3.1.0</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.0.patch.pck</File>
<Size>9840786</Size>
</Unit>
<Unit>
<Version>0.3.1.1</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.1.patch.pck</File>
<Size>6078721</Size>
</Unit>
<Unit>
<Version>0.3.1.2</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.2.patch.pck</File>
<Size>2319319</Size>
</Unit>
<Unit>
<Version>0.3.1.3</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.3.patch.pck</File>
<Size>2388</Size>
</Unit>
<Unit>
<Version>0.3.1.4</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.4.patch.pck</File>
<Size>15612426</Size>
</Unit>
<Unit>
<Version>0.3.1.5</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.5.patch.pck</File>
<Size>1263565</Size>
</Unit>
<Unit>
<Version>0.3.1.6</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.6.patch.pck</File>
<Size>14974089</Size>
</Unit>
<Unit>
<Version>0.3.1.7</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.7.patch.pck</File>
<Size>1006034</Size>
</Unit>
<Unit>
<Version>0.3.1.8</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.8.patch.pck</File>
<Size>41297</Size>
</Unit>
<Unit>
<Version>0.3.1.9</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.1.9.patch.pck</File>
<Size>3155570</Size>
</Unit>
<Unit>
<Version>0.3.2.0</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.0.patch.pck</File>
<Size>1595467</Size>
</Unit>
<Unit>
<Version>0.3.2.1</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.1.patch.pck</File>
<Size>16949</Size>
</Unit>
<Unit>
<Version>0.3.2.2</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.2.patch.pck</File>
<Size>3219</Size>
</Unit>
<Unit>
<Version>0.3.2.4</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.4.patch.pck</File>
<Size>15598</Size>
</Unit>
<Unit>
<Version>0.3.2.5</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.5.patch.pck</File>
<Size>782</Size>
</Unit>
<Unit>
<Version>0.3.2.6</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.6.patch.pck</File>
<Size>1690633</Size>
</Unit>
<Unit>
<Version>0.3.2.7</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.7.patch.pck</File>
<Size>372227</Size>
</Unit>
<Unit>
<Version>0.3.2.8</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.8.patch.pck</File>
<Size>222774</Size>
</Unit>
<Unit>
<Version>0.3.2.9</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.2.9.patch.pck</File>
<Size>7137360</Size>
</Unit>
<Unit>
<Version>0.3.3.0</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.0.patch.pck</File>
<Size>1143261</Size>
</Unit>
<Unit>
<Version>0.3.3.1</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.1.patch.pck</File>
<Size>12209767</Size>
</Unit>
<Unit>
<Version>0.3.3.2</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.2.patch.pck</File>
<Size>1407566</Size>
</Unit>
<Unit>
<Version>0.3.3.3</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.3.patch.pck</File>
<Size>432357</Size>
</Unit>
<Unit>
<Version>0.3.3.4</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.4.patch.pck</File>
<Size>3974477</Size>
</Unit>
<Unit>
<Version>0.3.3.5</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.5.patch.pck</File>
<Size>1153338</Size>
</Unit>
<Unit>
<Version>0.3.3.6</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.6.patch.pck</File>
<Size>368459</Size>
</Unit>
<Unit>
<Version>0.3.3.7</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.7.patch.pck</File>
<Size>38959</Size>
</Unit>
<Unit>
<Version>0.3.3.8</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.8.patch.pck</File>
<Size>85925</Size>
</Unit>
<Unit>
<Version>0.3.3.9</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.3.9.patch.pck</File>
<Size>881045</Size>
</Unit>
<Unit>
<Version>0.3.4.0</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.4.0.patch.pck</File>
<Size>4359</Size>
</Unit>
<Unit>
<Version>0.3.4.1</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.4.1.patch.pck</File>
<Size>327663</Size>
</Unit>
<Unit>
<Version>0.3.4.2</Version>
<!-- File format : [folder]/[filename] -->
<File>patch_pack/0.3.4.2.patch.pck</File>
<Size>329585</Size>
</Unit>
<Unit>
<Version>0.3.4.3</Version>
<File>patch_pack/0.3.4.3.patch.pck</File>
<Size>696909</Size>
</Unit>
<Unit>
<Version>0.3.4.4</Version>
<File>patch_pack/0.3.4.4.patch.pck</File>
<Size>696909</Size>
</Unit>
<Unit>
<Version>0.3.4.5</Version>
<File>patch_pack/0.3.4.5.patch.pck</File>
<Size>696909</Size>
</Unit>
<Unit>
<Version>0.3.4.6</Version>
<File>patch_pack/0.3.4.6.patch.pck</File>
<Size>696909</Size>
</Unit>
<Unit>
<Version>0.3.4.7</Version>
<File>patch_pack/0.3.4.7.patch.pck</File>
<Size>696909</Size>
</Unit>
<Unit>
<Version>0.3.4.8</Version>
<File>patch_pack/0.3.4.8.patch.pck</File>
<Size>696909</Size>
</Unit>
<Unit>
<Version>0.3.4.9</Version>
<File>patch_pack/0.3.4.9.patch.pck</File>
<Size>1090255</Size>
</Unit>
<Unit>
<Version>0.3.4.10</Version>
<File>patch_pack/0.3.4.10.patch.pck</File>
<Size>80406</Size>
</Unit>
<Unit>
<Version>0.3.4.11</Version>
<File>patch_pack/0.3.4.11.patch.pck</File>
<Size>80406</Size>
</Unit>
<Unit>
<Version>0.3.5.2</Version>
<File>patch_pack/0.3.5.2.patch.pck</File>
<Size>4408291</Size>
</Unit>
<Unit>
<Version>0.3.5.3</Version>
<File>patch_pack/0.3.5.3.patch.pck</File>
<Size>89</Size>
</Unit>
<Unit>
<Version>0.3.5.4</Version>
<File>patch_pack/0.3.5.4.patch.pck</File>
<Size>89</Size>
</Unit>
<Unit>
<Version>0.3.5.5</Version>
<File>patch_pack/0.3.5.5.patch.pck</File>
<Size>89</Size>
</Unit>
<Unit>
<Version>0.3.5.6</Version>
<File>patch_pack/0.3.5.6.patch.pck</File>
<Size>89</Size>
</Unit>
<Unit>
<Version>0.3.5.7</Version>
<File>patch_pack/0.3.5.7.patch.pck</File>
<Size>89</Size>
</Unit>
<Unit>
<Version>0.3.5.8</Version>
<File>patch_pack/0.3.5.8.patch.pck</File>
<Size>9</Size>
</Unit>
<Unit>
<Version>0.5.2.1</Version>
<File>patch_pack/0.5.2.1.patch.pck</File>
<Size>31284490</Size>
</Unit>
<Unit>
<Version>0.6.2.1</Version>
<File>patch_pack/0.6.2.1.patch.pck</File>
<Size>21419942</Size>
</Unit>
<Unit>
<Version>0.6.3.5</Version>
<File>patch_pack/0.6.3.5.patch.pck</File>
<Size>7081664</Size>
</Unit>
</PatchPacket>
<FilePatch>
<Unit>
<Version>0.3.0.0</Version>
<File>0.3.0.0.filelist.xml</File>
</Unit>
</FilePatch>
</root>