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);
复制代码
|