Sometimes, we have to use AutoIt script to edit an xml, add a node or remove a node, to make some deployment documents fitable to some project.

I have picked up a piece of script function about it as below:

Func append_node($SourceFile)
$objDom = ObjCreate("Microsoft.XMLDOM")
$objDom.load($SourceFile)
$objRoot = $objDom.documentElement.selectSingleNode('//Left') ;Add a child node
$child1 = $objDom.createElement("rootElement")
$child1.text = "Child1"
$child1.setAttribute("Att1Child1","Child1_TextAtt1")
$objRoot.appendChild($child1) ;Add a grandchild node
$objChild1 = $objDom.createElement("childElement1")
$objChild1.text = "objChild1"
$objChild1.setAttribute("Att1ObjChild1","obj_Child1_TextAtt1")
$child1.appendChild($objChild1) ;Add a grandchild node
$objChild2 = $objDom.createElement("childElement2")
$objChild2.text = "objChild2"
$objChild2.setAttribute("Att2ObjChild2","obj_Child2_TextAtt21")
$child1.appendChild($objChild2) $objDom.save($SourceFile)
EndFunc Func remove_node($SourceFile)
$oXML = ObjCreate("Microsoft.XMLDOM")
$oXML.Load($SourceFile)
$oNode = $oXML.documentElement.selectSingleNode('//Left')
;$oNode.parentNode.removeChild($oNode)
$remove_node = $oXML.documentElement.selectSingleNode('//Left/NewChild1')
;Remove the child node
$oNode.removeChild($remove_node)
$oXML.save($SourceFile)
EndFunc $SourceFile = "STRPControl.xml"
append_node($SourceFile)

AutoIt with XML: Add a child/grandchild node or remove any node的更多相关文章

  1. node.js&pm2搭建node生产环境

    node.js下载地址https://nodejs.org/en/download/stable/ 下载截图 建议采用稳定编译过的版本,source code稍麻烦,编译过的直接可用,安装超级简单,红 ...

  2. LeetCode解题报告—— 4Sum & Remove Nth Node From End of List & Generate Parentheses

    1. 4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + ...

  3. Node.js入门:Node.js&NPM的安装与配置

    Node.js安装与配置      Node.js已经诞生两年有余,由于一直处于快速开发中,过去的一些安装配置介绍多数针对0.4.x版本而言的,并非适合最新的0.6.x的版本情况了,对此,我们将在0. ...

  4. 63. Swap Nodes in Pairs && Rotate List && Remove Nth Node From End of List

    Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For exam ...

  5. LeetCode: Remove Nth Node From End of List 解题报告

    Remove Nth Node From End of List Total Accepted: 46720 Total Submissions: 168596My Submissions Quest ...

  6. Merge Two Sorted Lists & Remove Nth Node From End of List

    1.合并两个排好序的list Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The ...

  7. Leetcode 19——Remove Nth Node From End of List

    Given a linked list, remove the nth node from the end of list and return its head. For example, Give ...

  8. java Queue中 add/offer,element/peek,remove/poll区别

    转自https://blog.csdn.net/u012050154/article/details/60572567 java Queue中 add/offer,element/peek,remov ...

  9. 【Node.js】利用node.js搭建服务器并访问静态网页

    node.js是一门服务端的语言,下面讲讲如何利用node.js提供给我们的api来搭建服务器,并且访问静态网页 项目结构如下 ------------------------------------ ...

随机推荐

  1. PriorityQueue ,ArrayList , 数组排序

    static class E implements Comparable<E>{ int x ; int y ; int state ; int money ; public E(int ...

  2. Java中char转为16进制

    Java中char转为16进制 char a = '0'; String hexStr = Integer.toHexString(a); System.out.println(hexStr);

  3. 转:国内外著名开源b2c电子商务系统比较包括asp.net和php

    from: http://longdick.iteye.com/blog/1122879 国内外著名开源b2c电子商务系统比较包括asp.net和php 博客分类: 电子商务   国内外著名开源b2c ...

  4. C 标准库 - <setjmp.h>

    C 标准库 - <setjmp.h> 简介 setjmp.h 头文件定义了宏 setjmp().函数 longjmp() 和变量类型 jmp_buf,该变量类型会绕过正常的函数调用和返回规 ...

  5. electron 缓存目录 禁用缓存

    C:\Users\Administrator\AppData\Roaming\linksame // 禁用缓存 app.commandLine.appendSwitch("--disable ...

  6. Cocos2d-x初识

    cocos2d-x引擎是什么 在学习游戏的时候就有意的搜索这方面的知识,知道游戏须要游戏引擎,引擎听着非常厉害,只是就是一个游戏框架. 或许某一个游戏框架火起来了,就非常流行了,只是我觉得不论什么游戏 ...

  7. Phpstorm 放大字体的快捷键是什么?

      这个功能需要设置才能使用: 步骤:control+shift+A功能可以搜索对应功能 输入mouse 设置Change font size(Zoom) ...的按钮打开,然后就可以通过 ctrl+ ...

  8. Android pull to Refresh 导入出错?

    今天在导入 PuultoResfresh 的时候老是出错. error: [2014-09-28 10:04:44 - library] Unable to resolve target 'andro ...

  9. HDMI各版本对比

    转:一文看懂从HDMI1.0到HDMI2.1的历代规格变化 hdmi HDMI详解 https://blog.csdn.net/xubin341719/article/details/7713450 ...

  10. 基于Kubernetes 构建.NET Core技术中台

    今天下午在腾讯云+社区社区分享了<基于Kubernetes 构建.NET Core技术中台>,下面是演讲内容的文字实录. 我们为什么需要中台 我们现在处于企业信息化的新时代.为什么这样说呢 ...