Привет всем, это мой первый вопрос здесь.Я все еще изучаю английский, поэтому, пожалуйста, будьте осторожны со мной ...
Я начинающий программист на C ++.
Я пытаюсь создать программу, которая читает файл xml, выполняет некоторые операциина некоторые переменные, и напишите снова.
В XML-файле одна строка выглядит следующим образом:
<ItemDef Vnum="194" Name="ܧZы+4" LocalizedName="localizedname+4" Type="1" SubType="0" Weight="0" Size="2" AntiFlags="262188" Flags="1" WearFlags="16" ImmuneFlags="0" Gold="720000" ShopBuyPrice="720000" LimitType0="1" LimitValue0="75" LimitType1="0" LimitValue1="0" ApplyType0="7" ApplyValue0="21" ApplyType1="0" ApplyValue1="0" ApplyType2="0" ApplyValue2="0" Value0="0" Value1="67" Value2="98" Value3="90" Value4="110" Value5="30" Socket0="0" Socket1="0" Socket2="0" RefinedVnum="195" RefineSet="23" AlterToMagicItemPercent="0" Specular="30" GainSocketPercent="3" AddonType="0" />
<ItemDef Vnum="195" Name="ܧZы+5" LocalizedName="localizedname+5" Type="1" SubType="0" Weight="0" Size="2" AntiFlags="262444" Flags="1" WearFlags="16" ImmuneFlags="0" Gold="720000" ShopBuyPrice="720000" LimitType0="1" LimitValue0="75" LimitType1="0" LimitValue1="0" ApplyType0="7" ApplyValue0="22" ApplyType1="0" ApplyValue1="0" ApplyType2="0" ApplyValue2="0" Value0="0" Value1="63" Value2="96" Value3="90" Value4="110" Value5="40" Socket0="0" Socket1="0" Socket2="0" RefinedVnum="196" RefineSet="24" AlterToMagicItemPercent="0" Specular="40" GainSocketPercent="3" AddonType="0" />
<ItemDef Vnum="196" Name="ܧZы+6" LocalizedName="localizedname+6" Type="1" SubType="0" Weight="0" Size="2" AntiFlags="262444" Flags="1" WearFlags="16" ImmuneFlags="0" Gold="720000" ShopBuyPrice="720000" LimitType0="1" LimitValue0="75" LimitType1="0" LimitValue1="0" ApplyType0="7" ApplyValue0="23" ApplyType1="0" ApplyValue1="0" ApplyType2="0" ApplyValue2="0" Value0="0" Value1="56" Value2="93" Value3="90" Value4="110" Value5="51" Socket0="0" Socket1="0" Socket2="0" RefinedVnum="197" RefineSet="25" AlterToMagicItemPercent="0" Specular="50" GainSocketPercent="3" AddonType="0" />
<ItemDef Vnum="197" Name="ܧZы+7" LocalizedName="localizedname+7" Type="1" SubType="0" Weight="0" Size="2" AntiFlags="262444" Flags="1" WearFlags="16" ImmuneFlags="0" Gold="720000" ShopBuyPrice="720000" LimitType0="1" LimitValue0="75" LimitType1="0" LimitValue1="0" ApplyType0="7" ApplyValue0="24" ApplyType1="0" ApplyValue1="0" ApplyType2="0" ApplyValue2="0" Value0="0" Value1="46" Value2="87" Value3="90" Value4="110" Value5="63" Socket0="0" Socket1="0" Socket2="0" RefinedVnum="198" RefineSet="26" AlterToMagicItemPercent="0" Specular="65" GainSocketPercent="3" AddonType="0" />
<ItemDef Vnum="198" Name="ܧZы+8" LocalizedName="localizedname+8" Type="1" SubType="0" Weight="0" Size="2" AntiFlags="262444" Flags="1" WearFlags="16" ImmuneFlags="0" Gold="720000" ShopBuyPrice="720000" LimitType0="1" LimitValue0="75" LimitType1="0" LimitValue1="0" ApplyType0="7" ApplyValue0="25" ApplyType1="0" ApplyValue1="0" ApplyType2="0" ApplyValue2="0" Value0="0" Value1="29" Value2="79" Value3="90" Value4="110" Value5="76" Socket0="0" Socket1="0" Socket2="0" RefinedVnum="199" RefineSet="27" AlterToMagicItemPercent="0" Specular="80" GainSocketPercent="3" AddonType="0" />
<ItemDef Vnum="199" Name="ܧZы+9" LocalizedName="localizedname+9" Type="1" SubType="0" Weight="0" Size="2" AntiFlags="262444" Flags="1" WearFlags="16" ImmuneFlags="0" Gold="720000" ShopBuyPrice="720000" LimitType0="1" LimitValue0="75" LimitType1="0" LimitValue1="0" ApplyType0="7" ApplyValue0="26" ApplyType1="0" ApplyValue1="0" ApplyType2="0" ApplyValue2="0" Value0="0" Value1="5" Value2="67" Value3="90" Value4="110" Value5="90" Socket0="0" Socket1="0" Socket2="0" RefinedVnum="0" RefineSet="0" AlterToMagicItemPercent="0" Specular="100" GainSocketPercent="3" AddonType="0" />
, и мне нужно выполнить некоторые операции с одной или несколькими данными.Например, измените LimitType0 со всех строк или +1 на все номера Antiflag
Как я могу это сделать?Вот мой ужасный прогресс до сих пор:
using namespace std;
#include <fstream>
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <cstring>
int main() {
string name, localizedname;
int Vnum, Type, SubType, Weight, Size, AntiFlags, Flags, WearFlags, ImmuneFlags;
int Gold, ShopBuyPrice, LimitType0, LimitValue0, LimitType1, LimitValue1, ApplyType0;
int ApplyValue0, ApplyType1, ApplyValue1, ApplyType2, ApplyValue2, Value0, Value1;
int Value2, Value3, Value4, Value5, Socket0, Socket1, Socket2, RefinedVnum, RefineSet, AlterToMagicItemPercent, Specular, GainSocketPercent, AddonType;
ofstream yaz("proto_new.xml", ios::app);
ifstream fileread("proto.xml");
while (!fileread.eof()){
//ı dont know what should ı write here...
}
fileread.close();
yourfile.close();
return 0;
}