[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 【已解决】求助批处理从一个XML中提取需要的内容写到csv中

本帖最后由 zhengwei007 于 2024-11-23 17:14 编辑

就只有一个文件,但里面内容太多,手动不太现实,我截取一段代码:
  1. <?xml version='1.0' encoding='utf-8'?>
  2. <list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/ExtractableItems.xsd">
  3. <item id="7629"> <!-- Looted Goods - White Cargo box -->
  4. <extract id="6688" quantity="1" chance="9" /> <!-- Forgotten Blade Edge -->
  5. <extract id="6689" quantity="1" chance="9" /> <!-- Basalt Battlehammer Head -->
  6. <extract id="6690" quantity="1" chance="9" /> <!-- Imperial Staff Head -->
  7. <extract id="6691" quantity="1" chance="9" /> <!-- Angel Slayer Blade -->
  8. <extract id="6693" quantity="1" chance="9" /> <!-- Dragon Hunter Axe Blade -->
  9. <extract id="6694" quantity="1" chance="9" /> <!-- Saint Spear Blade -->
  10. <extract id="6695" quantity="1" chance="9" /> <!-- Demon Splinter Blade -->
  11. <extract id="6696" quantity="1" chance="9" /> <!-- Heavens Divider Edge -->
  12. <extract id="6697" quantity="1" chance="9" /> <!-- Arcana Mace Head -->
  13. <extract id="7579" quantity="1" chance="9" /> <!-- Draconic Bow Shaft -->
  14. <extract id="57" quantity="330000" chance="10" /> <!-- Adena -->
  15. </item>
  16. <item id="7631"> <!-- Looted Goods - Yellow Cargo box -->
  17. <extract id="6701" quantity="1" chance="20" /> <!-- Sealed Imperial Crusader Breastplate Part -->
  18. <extract id="6702" quantity="1" chance="20" /> <!-- Sealed Imperial Crusader Gaiters Pattern -->
  19. <extract id="6707" quantity="1" chance="20" /> <!-- Sealed Draconic Leather Armor Part -->
  20. <extract id="6711" quantity="1" chance="20" /> <!-- Sealed Major Arcana Robe Part -->
  21. <extract id="57" quantity="930000" chance="20" /> <!-- Adena -->
  22. </item>
  23. <item id="6505"> <!-- Orange Treasure Chest -->
  24. <extract id="6910" quantity="3" chance="58" /> <!-- Premium Fish Oil -->
  25. <extract id="-1" quantity="0" chance="42" /> <!-- Nothing -->
  26. </item>
  27. </list>
复制代码
以上代码通过批处理,希望得到以下内容,主要提取itemID,extractID,quantity,chance,结果如下:
  1. item id,extract id,quantity, chance
  2. 7629,6688,1,9
  3. 7629,6689,1,9
  4. 7629,6690,1,9
  5. 7629,6691,1,9
  6. 7629,6693,1,9
  7. 7629,6694,1,9
  8. 7629,6695,1,9
  9. 7629,6696,1,9
  10. 7629,6697,1,9
  11. 7629,7579,1,9
  12. 7629,57,330000,10
  13. 7631,6701,1,20
  14. 7631,6702,1,20
  15. 7631,6707,1,20
  16. 7631,6711,1,20
  17. 7631,57,930000,20
  18. 6505,6910,3,58
  19. 6505,-1,0,42
复制代码
以上是最终结果,就是把itemid排一下,有几个extract id,就填充几个item id。
注:最后一行的-1可以不要,麻烦我自己筛选删除也行。
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2

感谢两位,都能使用,小1万行瞬间完成。

TOP

返回列表