标题: [数值计算] bat批量修改xml里某个值的数据 [打印本页]
作者: 巴啦啦能量 时间: 2018-10-8 21:24 标题: bat批量修改xml里某个值的数据
<data>
<mzm.gsp.monster.confbean.SMonsterCfg catchRate="0" catchedMonsterId="0" categoryId="12" classLevel="4" classType="6" gender="1" groupId="1" id="120381150" levelHigh="200" levelLow="0" modelColorId="0" modelFigureId="0" monsterModelId="700301137" monsterSkillProbBase="10000" monsterStrategy="LHXK_littleTY" name="南疆獸王" propertyTierId="5" rewardTableId="0" typeId="3">
<monsterSkillProbs>
<no-comparator />
<entry>
<int>10000</int>
<int>110598001</int>
</entry>
</monsterSkillProbs>
<props>
<no-comparator />
<entry>
<int>1</int>
<float>7.2</float>
</entry>
<entry>
<int>3</int>
<float>100.0</float>
</entry>
<entry>
<int>5</int>
<float>3</float>
</entry>
<entry>
<int>7</int>
<float>3.6</float>
</entry>
<entry>
<int>8</int>
<float>3.39</float>
</entry>
</props>
</mzm.gsp.monster.confbean.SMonsterCfg>
</data>
用bat批量修改xml里面<float>里面的值
例如增加0.85倍要如何修改呢
作者: flashercs 时间: 2018-10-9 00:30
float.js- function parseXML(dom) {
- var myErr;
- if (0 !== dom.parseError.errorCode) {
- myErr = dom.parseError;
- WScript.Echo([
- "XML parse error",
- 'reason: ' + myErr.reason,
- 'code: ' + (myErr.errorCode >>> 0).toString(16),
- 'filepos: ' + myErr.filepos,
- 'line: ' + myErr.line,
- 'linepos: ' + myErr.linepos,
- 'srcText: ' + myErr.srcText,
- 'url: ' + myErr.url
- ].join('\n'));
- return false;
- }
- return true;
- }
- function makeDOM() {
- var dom = null;
- var aXMLHttpVers = ['Msxml2.DOMDocument.6.0', 'Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument'];
- for (var i = 0; i < aXMLHttpVers.length; i++) {
- try {
- dom = WScript.CreateObject(aXMLHttpVers[i]);
- break;
- } catch (error) { }
- }
- if (dom === null) return dom;
- dom.async = false;
- dom.validateOnParse = false;
- dom.resolveExternals = false;
- dom.setProperty('AllowDocumentFunction', false);
- dom.setProperty('AllowXsltScript', false);
- dom.setProperty('MaxElementDepth', 256);
- dom.setProperty('ProhibitDTD', true);
- dom.setProperty('SelectionLanguage', 'XPath');
- return dom;
- }
- var file = 'data.xml',//要修改的XML文件
- xmlDoc = makeDOM(),
- oSelection;
- if (null === xmlDoc) WScript.Quit(1);
- xmlDoc.load(file);
- if (!parseXML(xmlDoc)) WScript.Quit(2);
- oSelection = xmlDoc.selectNodes('//float/text()');
- while (node = oSelection.nextNode()) {
- node.nodeValue *= 1.85;
- }
- xmlDoc.save(file);
复制代码
作者: WHY 时间: 2018-10-9 11:32
- PowerShell "[xml]$xml=type 'a.xml'; $xml | Select-XML '//float' | ForEach{$_.Node.InnerText=0.85*$_.Node.InnerText}; $xml.Save('b.xml')"
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |