remove namespace from xml config file
从xml配置文件中移除命令空间
https://stackoverflow.com/questions/987135/how-to-remove-all-namespaces-from-xml-with-c
string xml = node.OuterXml;
//Regex below finds strings that start with xmlns, may or may not have :and some text, then continue with =
//and ", have a streach of text that does not contain quotes and end with ". similar, will happen to an attribute
// that starts with xsi.
string strXMLPattern = @"xmlns(:\w+)?=""([^""]+)""|xsi(:\w+)?=""([^""]+)""";
xml = Regex.Replace(xml, strXMLPattern, "");
/// <summary>
/// config section to remove in patch
/// </summary>
private List<string> _removeList; /// <summary>
/// appSettings will keep in patch(if exist in patch)
/// </summary>
private List<string> _usefulAppSettings; /// <summary>
/// xpath for appSettings section to remove in patch
/// </summary>
private string _appSettingsToRemove; private void InitIgnoreList()
{
InitAppSettingsToRemove();
_removeList = new List<string>
{
"/configuration/connectionStrings",
"/configuration/system.web/customErrors",
_appSettingsToRemove
};
} private void InitAppSettingsToRemove()
{
//xPath = "/configuration/appSettings/add[(@key!='CMSProgrammingLanguage' and @key!='WS.webservice') ]";
_usefulAppSettings = new List<string>
{
"CMSProgrammingLanguage",
"WS.webservice",
"ChartImageHandler",
"PageInspector:ServerCodeMappingSupport",
"ValidationSettings:UnobtrusiveValidationMode",
"LISALastUpdatedVersionTime",
"LISAUpdatedVersion"
};
var temp1 = "/configuration/appSettings/add[({0})]";
var temp2 = "@key!='{0}'"; //key not equal
var temp3 = string.Join(" and ", _usefulAppSettings.Select(x => string.Format(temp2, x)));
_appSettingsToRemove = string.Format(temp1, temp3);
}
remove namespace from xml config file的更多相关文章
- Create a custom configSection in web.config or app.config file
config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> ...
- Modifying namespace in XML document programmatically
Modifying namespace in XML document programmatically static XElement stripNS(XElement root) { return ...
- MVC模式下unity配置,报错“No connection string named '**Context' could be found in the application config file”
写在前面: 第一次配置时好好的,后来第二次改到MVC模式,把依赖注入写成字典的单例模式时,由于新建的ORM(数据库映射模型EF),怎么弄都不用,一直报错"No connection str ...
- Camel routes in Spring config file
The normal spring bean definition configuration file, the xsi:schemaLocation only has two: beans and ...
- The web.config file for this project is missing the required DirectRequestModule.
The web.config file for this project is missing the required DirectRequestModule. 将应用程序集的模式由集成改为经典 ...
- Can not find connection pool config file
暂时未解决 checkActivation=====================true Can Not Parse ConnectionCfg! 2019/10/12-11:23:38 > ...
- [笔记]HAproxy reload config file with uninterrupt session
HAProxy is a high performance load balancer. It is very light-weight, and free, making it a great op ...
- error in config file "/etc/rabbitmq/rabbitmq.config"
记录一次RabbitMQ配置文件配置错误 error信息: dill@ubuntu-vm:/usr/share/doc/rabbitmq-server$ sudo /usr/lib/rabbitmq/ ...
- .NET错误The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework
错误描述: The 'targetFramework' attribute in the <compilation> element of the Web.config file is u ...
随机推荐
- 梦想CAD控件安卓文字样式
增加文字样式 用户可以增加文字样式到数据库,并设置其字体等属性,具体实现代码如下: // 增加文字样式 //getCurrentDatabase()返回当前数据库对象 //getTextstyle() ...
- JavaScipt30(第八个案例)(主要知识点:canvas)
承接上文,这是第8个案例,要实现的效果是按住鼠标不放,进行拖动时可以在画布上画出不同粗细不同颜色的曲线. 附上项目链接: https://github.com/wesbos/JavaScript30 ...
- 02C语言基本语法
C语言基本语法 注释 //行注释 /* 块注释*/ 标识符 标识符是用来标识变量.函数.任何其他用户自定义项目的名称:一个标识符以字母 A-Z 或 a-z 或下划线 _ 开始,后跟零个或多个字母.下划 ...
- 04Microsoft SQL Server 数据库创建,查看,使用,修改及删除
Microsoft SQL Server 数据库创建,查看,使用,修改及删除 创建数据库 创建普通数据库 USE [master] GO CREATE DATABASE [MyDataBase] -- ...
- 【原】CentOS release 6.2 安装mysql
1. yum update升级以后的系统版本为 [root@yl-web yl]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (C ...
- 如何快速的vue init 属于自己的vue模板?
相信很多接触过vue的小伙伴非常熟悉了,我们在开启项目之前都需要vue init webpack xx来初始化自己的项目目录.但是在实际开发中我们往往会根据公司要求或者业务的需要会对目录进行局部的调整 ...
- 数列分块入门1-9 By hzwer
声明 持续更新,因为博主也是正在学习分块的知识,我很菜的,菜的抠$jio$ 写在前面 分块是个很暴力的算法,但却比暴力优秀的多,分块算法的时间复杂度一般是根号的,他的主要思想是将一个长度是$n$的数列 ...
- Tree(树的还原以及树的dfs遍历)
紫书:P155 uva 548 You are to determine the value of the leaf node in a given binary tree that is th ...
- [转] 探讨JS合并两个数组的方法
我们在项目过程中,有时候会遇到需要将两个数组合并成为一个的情况. 比如: 1 2 var a = [1,2,3]; var b = [4,5,6]; 有两个数组a.b,需求是将两个数组合并成一个.方法 ...
- 实用型的DJANGO ORM
比较深入一点的内容,需要用时,用心看看. URL: https://www.sitepoint.com/doing-more-with-your-django-models/ https://www. ...