标题:
[文本处理]
批处理如何从txt文本读取内容并按指定格式和要求生成xml文件?
[打印本页]
作者:
wjrawlinson
时间:
2016-4-21 16:33
标题:
批处理如何从txt文本读取内容并按指定格式和要求生成xml文件?
本帖最后由 pcl_test 于 2016-4-21 19:45 编辑
批处理 如何生成预期的xml文件,求助!
xml文件模板如下:
<?xml version="1.0" encoding="UTF-8"?>
<DeviceList>
<device mac="AA:AA:AA:AA:AA:AA">
<terminal mac="CC:CC:CC:00:00:00" mode="2" sendpackagespeed="13000000" cumulativeTraffic="6552146115" hostname="test01" />
<terminal mac="CC:CC:CC:00:00:01" mode="2" sendpackagespeed="13000000" cumulativeTraffic="3146115" hostname="test02" />
<terminal mac="CC:CC:CC:00:00:02" mode="2" sendpackagespeed="13000000" cumulativeTraffic="3146115" hostname="test03" />
<terminal mac="CC:CC:CC:00:00:03" mode="2" sendpackagespeed="13000000" cumulativeTraffic="3146115" hostname="test04" />
<terminal mac="CC:CC:CC:00:00:04" mode="2" sendpackagespeed="13000000" cumulativeTraffic="3146115" hostname="test05" />
<terminal mac="CC:CC:CC:00:00:05" mode="2" sendpackagespeed="10000000" cumulativeTraffic="3146115" hostname="test06" />
<terminal mac="CC:CC:CC:00:00:06" mode="2" sendpackagespeed="10000000" cumulativeTraffic="3146115" hostname="test07" />
<terminal mac="CC:CC:CC:00:00:07" mode="2" sendpackagespeed="10000000" cumulativeTraffic="3146115" hostname="test08" />
<terminal mac="CC:CC:CC:00:00:08" mode="2" sendpackagespeed="10000000" cumulativeTraffic="3146115" hostname="test09" />
<terminal mac="CC:CC:CC:00:00:09" mode="2" sendpackagespeed="10000000" cumulativeTraffic="3146115" hostname="test10" />
</device>
<device mac="AA:AA:AA:AA:AA:AA">
<terminal mac="CC:CC:CC:00:00:00" mode="0" sendpackagespeed="6000000" cumulativeTraffic="6552146115" hostname="test01" />
<terminal mac="CC:CC:CC:00:00:01" mode="0" sendpackagespeed="6000000" cumulativeTraffic="3146115" hostname="test02" />
<terminal mac="CC:CC:CC:00:00:02" mode="0" sendpackagespeed="6000000" cumulativeTraffic="3146115" hostname="test03" />
<terminal mac="CC:CC:CC:00:00:03" mode="0" sendpackagespeed="6000000" cumulativeTraffic="3146115" hostname="test04" />
<terminal mac="CC:CC:CC:00:00:04" mode="0" sendpackagespeed="6000000" cumulativeTraffic="3146115" hostname="test05" />
<terminal mac="CC:CC:CC:00:00:05" mode="0" sendpackagespeed="4000000" cumulativeTraffic="3146115" hostname="test06" />
<terminal mac="CC:CC:CC:00:00:06" mode="0" sendpackagespeed="4000000" cumulativeTraffic="3146115" hostname="test07" />
<terminal mac="CC:CC:CC:00:00:07" mode="0" sendpackagespeed="4000000" cumulativeTraffic="3146115" hostname="test08" />
<terminal mac="CC:CC:CC:00:00:08" mode="0" sendpackagespeed="4000000" cumulativeTraffic="3146115" hostname="test09" />
<terminal mac="CC:CC:CC:00:00:09" mode="0" sendpackagespeed="4000000" cumulativeTraffic="3146115" hostname="test10" />
</device>
</DeviceList>
需要的xml文件里共有30000个device mac,每一个device mac下有10个terminal mac,device mac值从一个存有30000个mac地址的txt文件中依次获取,每个device mac下的10个terminal mac地址要求不能重复,请大神给予帮助,感谢万分!!!
30000个mac地址的txt文件如下:
...
BB:BB:BB:00:00:00
BB:BB:BB:00:00:01
BB:BB:BB:00:00:02
BB:BB:BB:00:00:03
BB:BB:BB:00:00:04
BB:BB:BB:00:00:05
BB:BB:BB:00:00:06
BB:BB:BB:00:00:07
BB:BB:BB:00:00:08
BB:BB:BB:00:00:09
BB:BB:BB:00:00:10
...
欢迎光临 批处理之家 (http://bbs.bathome.net/)
Powered by Discuz! 7.2