C ++读取行并编辑一些信息

时间:2019-03-19 06:24:12

标签: c++ row edit

大家好,这是我在这里的第一个问题。我仍在学习英语,所以请对我温柔...

我是初学者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;



    }

0 个答案:

没有答案