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来搭建服务器,并且访问静态网页 项目结构如下 ------------------------------------ ...
随机推荐
- fast-cgi & php-fpm 等的理解
原文地址:https://segmentfault.com/q/1010000000256516 网上有的说,fastcgi是一个协议,php-fpm实现了这个协议: 有的说,php-fpm是fast ...
- python 工具mouse_find 鼠标定位
import os,time import pyautogui as pag try: while True: print ("Press Ctrl-C to end") x,y ...
- Python下opencv使用笔记(七)(图像梯度与边缘检測)
梯度简单来说就是求导,在图像上表现出来的就是提取图像的边缘(无论是横向的.纵向的.斜方向的等等),所须要的无非也是一个核模板.模板的不同结果也不同.所以能够看到,全部的这些个算子函数,归结究竟都能够用 ...
- [Algorithm] Breadth First JavaScript Search Algorithm for Graphs
Breadth first search is a graph search algorithm that starts at one node and visits neighboring node ...
- Solaris主机间的信任关系机制
解决问题: 管理员经常在其他服务器之间登录,是否需要密码切换. 知识点:主机间信任关系.R 命令集 /etc/hosts/equiv 文件 R服务是不加密的,别人可以破解. 主机名 + 用户名. + ...
- Spring Boot中使用RSocket
1. 概述 RSocket应用层协议支持 Reactive Streams语义, 例如:用RSocket作为HTTP的一种替代方案.在本教程中, 我们将看到RSocket用在spring boot中, ...
- 【推荐】初级.NET程序员,你必须知道的EF知识和经验
阅读目录 推荐MiniProfiler插件 数据准备 foreach循环的陷进 AutoMapper工具 联表查询统计 性能提升之AsNonUnicode 性能提升之AsNoTracking 多字 ...
- C#用Infragistics 导入导出Excel
最近项目中有数据的导入导出Excel的需求,这里做简单整理. 公司用的是Infragistics的产品,付费,不需要本地安装Office. 有需要的朋友可以下载 Infragistics.2013.2 ...
- [Python爬虫] Selenium自己主动訪问Firefox和Chrome并实现搜索截图
前两篇文章介绍了安装.此篇文章算是一个简单的进阶应用吧.它是在Windows下通过Selenium+Python实现自己主动訪问Firefox和Chrome并实现搜索截图的功能. [Python爬虫] ...
- 获取本地IP V4 出现::1
获取本地IP V4 竟然得到 ::1 和 192.168.x.xxx 多出来一个::1???? 终于在网络找到答案,原来是禁用了IP V6 导致,重新勾选IP V6,或者卸载IP V6 都可以解决问 ...