xml 操作(动态添加 property属性 其他节点同理)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using System.Xml.Linq;
using System.Xml;
using System.Windows.Forms; namespace ConsoleApplication27
{
class Program
{
[STAThread]
static void Main(string[] args)
{
var folderPath = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Mapping";
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
folderPath = fbd.SelectedPath;
} var files = System.IO.Directory.GetFiles(folderPath); foreach (string file in files)
{ if (!file.Contains(".hbm.xml")) { continue; }
var path = file; //AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Mapping\\PosPositionProductMapping.hbm.xml";
XmlDocument doc = new XmlDocument();
doc.Load(path);
var plist = doc.GetElementsByTagName("property"); bool find1 = false;
bool find2 = false;
foreach (XmlNode item in plist)
{ if (find1 == false)
find1 = item.Attributes["column"].Value.ToLower().Contains("CREATED_EMPLOYEE_NAME".ToLower());
if (find2 == false)
find2 = item.Attributes["column"].Value.ToLower().Contains("CREATED_EMPLOYEE_ID".ToLower()); }
var cls = doc.GetElementsByTagName("class")[];
if (find1 == false)
{
var e1 = doc.CreateElement("property", doc.DocumentElement.NamespaceURI);
e1.SetAttribute("column", "CREATED_EMPLOYEE_NAME");
e1.SetAttribute("name", "CreatedEmployeeName");
e1.SetAttribute("update", "false");
cls.AppendChild(e1);
}
if (find2 == false)
{
var e2 = doc.CreateElement("property", doc.DocumentElement.NamespaceURI);
e2.SetAttribute("column", "CREATED_EMPLOYEE_ID");
e2.SetAttribute("name", "CreatedEmployeeId");
e2.SetAttribute("update", "false");
cls.AppendChild(e2);
}
doc.Save(path);
MessageBox.Show("提示", "成功");
} }
}
}
xml 操作(动态添加 property属性 其他节点同理)的更多相关文章
- python装饰器、继承、元类、mixin,四种給类动态添加类属性和方法的方式(一)
介绍装饰器.继承.元类.mixin,四种給类动态添加类属性和方法的方式 有时候需要給类添加额外的东西,有些东西很频繁,每个类都需要,如果不想反复的复制粘贴到每个类,可以动态添加. # coding=u ...
- 第六种方式,python使用cached_property缓存装饰器和自定义cached_class_property装饰器,动态添加类属性(三),selnium webdriver类无限实例化控制成单浏览器。
使用 from lazy_object_proxy.utils import cached_property,使用这个装饰器. 由于官方的行数比较少,所以可以直接复制出来用自己的. class cac ...
- hadoop集群中动态添加新的DataNode节点
集群中现有的计算能力不足,须要另外加入新的节点时,使用例如以下方法就能动态添加新的节点: 1.在新的节点上安装hadoop程序,一定要控制好版本号,能够从集群上其它机器cp一份改动也行 2.把name ...
- 导航栏动态添加act属性
最近做了一个网站,需要设置导航栏的act属性,这里需要用到addClass以及removeClass: $('#topName li').removeClass('active'); $(this). ...
- vue 动态添加对象属性
昨天使用vue发现直接给对象添加属性,并不能触发响应更新,后来看文档发现要通过this.$set 函数动态添加才可用,eg: this.$set( obj, key, data)
- jquery 操作动态添加的元素
动态添加的元素,无法侦听到事件,写法如下: 使用函数.on 格式为: $(父元素).on('event','selector',function(){ //do something }) 例如 < ...
- python__高级 : 动态添加 对象属性, 类属性, 对象实例方法, 类静态方法, 类方法
给对象添加实例属性,可以直接这样 t.age = 18 ( 假设 t = Test() ) 给类添加类属性 , 也可以直接这样 Test.age = 18 那给对象添加实例方法,可以在类外面 ...
- vue中如何动态添加readonly属性
动态绑定input的readonly属性 1 <inpu :readonly="status ? false : 'readonly'"> status 为 false ...
- jQuery - 02. 样式表属性操作/类操作、动画、显示隐藏、滑入、淡入、停止动画、节点操作、添加对象、清空节点
样式表属性操作.css $("div").css({'width':100,'height':100,'background':'red'}); $("div" ...
随机推荐
- C#网络编程(异步传输字符串) - Part.3
这篇文章我们将前进一大步,使用异步的方式来对服务端编程,以使它成为一个真正意义上的服务器:可以为多个客户端的多次请求服务.但是开始之前,我们需要解决上一节中遗留的一个问题. 消息发送时的问题 这个问题 ...
- MDK中STM32使用Printf函数详细解析【转载】
在用MDK调试STM32板子串口时,为了方便串口调试,调用了printf()函数,用Keil仿真是,串口不能正确的输出,软件仿真时,总是卡在那 里.有点纳闷,然后调用USART_SendData()函 ...
- 不让activity显示UI的办法
直接把 //setContentView(R.layout.activity_welcome); 注释掉就是了
- 苹果手机 iTunes 资料备份到另一手机
百度教程 https://jingyan.baidu.com/article/d621e8da332e602865913f8e.html 直接使用iTunes将老手机的资料备份, (可能需要关闭手机定 ...
- linux解压缩基本命令使用
解压缩命令1.gzip 只能压缩文件,不可压缩目录,压缩后不保留原文件gzip a.txt会删除原文件 生成.gz后缀的文件 a.txt.gz2.gunzip解压.gz的文件gzip -d a.txt ...
- JS面向对象编程,对象,属性,方法。
document.write('<script type="text/javascript" src="http://api.map.baidu.com/api?v ...
- 使用airmon-ng工具开启监听模式
使用ifconfig命令查看活动的网络接口 可以看出网卡已经激活了,然后将网卡设置为混杂模式 root@sch01ar:~# airmon-ng start wlan0 用ifconfig查看网卡是否 ...
- numpy的一些用法
安装numpy windows安装pip即可,具体方法参考pip官网 http://pip-cn.readthedocs.io/en/latest/installing.html 安装方法:pip i ...
- leetcode905
vector<int> sortArrayByParity(vector<int>& A) { vector<int> EVEN;//偶数 vector&l ...
- EasyUI应用总结
1 <%@ page language="java" contentType="text/html; charset=utf-8" 2 pageEncod ...