- 帖子
- 890
- 积分
- 1475
- 技术
- 190
- 捐助
- 0
- 注册时间
- 2021-10-13
|
本帖最后由 aloha20200628 于 2024-11-21 00:16 编辑
回复 1# zhengwei007
以下代码针对一楼示例样本 1.xml,结果文件为 new.xml,假定同名字段(如 pAtk,mAtk)共在一个节点内(如 <for ... >)- @echo off &setlocal enabledelayedexpansion
- set "lst=,item id, type, name,icon,bodypart,armor_type,weight,soulshots,spiritshots,crystal_type,p_dam,rnd_dam,weapon_type,critical,hit_modify,atk_speed,m_dam,price,sellable,dropable,tradeable,pAtk,mAtk,rCrit,accCombat,pAtkSpd,pAtk1,mAtk1,pDef,"
- set "v=!lst!"
- (echo,item,type,name,icon,bodypart,armor_type,weight,soulshots,spiritshots,crystal_type,p_dam,rnd_dam,weapon_type,critical,hit_modify,atk_speed,m_dam,price,sellable,dropable,tradeable,pAtk,mAtk,rCrit,accCombat,pAtkSpd,pAtk1,mAtk1,pDef
- for /f tokens^=1-7^delims^=^ ^<^=^" %%a in (
- 'findstr /rbi /c:" *.*=\"^" /c:" ^</item^>" "1.xml" ') do (
- if /i "%%a"=="item id" (
- set "v=!v:%%a,=%%b,!"&set "v=!v:%%c,=%%d,!"&set "v=!v:%%e,=%%f,!"
- ) else if "%%e"==" />" (set "v=!v:%%b,=%%d,!"
- ) else if "%%g"==" />" (
- set "go=1"&for %%s in ("%%f","%%f1") do if defined go if "!v:%%~s,=%%b,!" neq "!v!" (
- set "go="&set "v=!v:%%~s,=%%b,!")
- ) else if /i "%%a"=="/item>" ((for %%s in (!lst!) do set "v=!v:,%%s,=,,!")&echo,!v:~1,-1!&set "v=!lst!")
- ))>"new.xml"
- endlocal&pause&exit/b
复制代码
|
|