AutoIt with XML: Add a child/grandchild node or remove any node
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的更多相关文章
- node.js&pm2搭建node生产环境
node.js下载地址https://nodejs.org/en/download/stable/ 下载截图 建议采用稳定编译过的版本,source code稍麻烦,编译过的直接可用,安装超级简单,红 ...
- 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 + ...
- Node.js入门:Node.js&NPM的安装与配置
Node.js安装与配置 Node.js已经诞生两年有余,由于一直处于快速开发中,过去的一些安装配置介绍多数针对0.4.x版本而言的,并非适合最新的0.6.x的版本情况了,对此,我们将在0. ...
- 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 ...
- LeetCode: Remove Nth Node From End of List 解题报告
Remove Nth Node From End of List Total Accepted: 46720 Total Submissions: 168596My Submissions Quest ...
- 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 ...
- 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 ...
- java Queue中 add/offer,element/peek,remove/poll区别
转自https://blog.csdn.net/u012050154/article/details/60572567 java Queue中 add/offer,element/peek,remov ...
- 【Node.js】利用node.js搭建服务器并访问静态网页
node.js是一门服务端的语言,下面讲讲如何利用node.js提供给我们的api来搭建服务器,并且访问静态网页 项目结构如下 ------------------------------------ ...
随机推荐
- CSRF攻击 & XSS攻击
之前有几篇文章写了 SQL注入类问题: http://www.cnblogs.com/charlesblc/p/5987951.html (介绍) http://www.cnblogs.com/cha ...
- 您也使用托管C++吗? 【转】
http://blog.csdn.net/Muf/article/details/656920 转向.NET后,手头上往往仍有旧的模块要重用.也许这些模块是Delphi写的,也许是C/C++写的,或者 ...
- Keras学习
参加比赛用到了keras,虽然之前用tensorflow,但是感觉tensorflow的确不太友好,api比较难读,然后就学习keras使用 随着深入,发现keras的api确实比较友好 跑了一些ex ...
- HDU2256-Problem of Precision(矩阵构造+高速幂)
pid=2256">题目链接 题意:求sqrt(sqrt(2) + sqrt(3)) ^ 2n MOD 1024 思路: 代码: #include <iostream> # ...
- (一)MVVMLight安装
http://www.cnblogs.com/manupstairs/p/4890300.html 1.首先新建一个wpf项目 2. 安装完成即可在我们的项目中看到如下引用: 如果点击安装的时候出现: ...
- 无线热点登陆认证原理探究---captive portal
什么是Captive Portal 大家肯定都连过公共场所的wifi热点,比如麦当劳等地方的.他们的wifi往往一连上去就会弹出一个要求登录或者微信关注之类的页面,只有在这个页面完成操作了才能正常访问 ...
- nightwatch.js - scroll until element is visible
.getLocationInView() Determine an element's location on the screen once it has been scrolled into vi ...
- g++ 6.4编译opencv-2.4.10报错记录
fetch公司的项目进行编译,此项目依赖opencv库.由于本人一直比较偏爱fedora,但也因此给我带来了许多"乐趣"(麻烦).fedora一直走得比较前沿,g++ 6.3了 ...
- input 的read only 和 disable的区别
read only ---------->只能读,不能操作,但是数据可以提交 disable -------------->控件被禁用,数据不能提交
- 发送邮件程序报错454 Authentication failed以及POP3和SMTP简介
一.发现问题 在测试邮件发送程序的时候,发送给自己的QQ邮箱,程序报错454 Authentication failed, please open smtp flag first. 二.解决问题 进入 ...