博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
remove namespace from xml config file
阅读量:6825 次
发布时间:2019-06-26

本文共 1976 字,大约阅读时间需要 6 分钟。

从xml配置文件中移除命令空间

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, "");

 

 

///         /// config section to remove in patch        ///         private List
_removeList; ///
/// appSettings will keep in patch(if exist in patch) /// private List
_usefulAppSettings; ///
/// xpath for appSettings section to remove in patch /// private string _appSettingsToRemove; private void InitIgnoreList() { InitAppSettingsToRemove(); _removeList = new List
{ "/configuration/connectionStrings", "/configuration/system.web/customErrors", _appSettingsToRemove }; } private void InitAppSettingsToRemove() { //xPath = "/configuration/appSettings/add[(@key!='CMSProgrammingLanguage' and @key!='WS.webservice') ]"; _usefulAppSettings = new List
{ "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); }

 

转载地址:http://ufrzl.baihongyu.com/

你可能感兴趣的文章
面向.Net程序员的前端优化
查看>>
HTTPS到底是个什么鬼?
查看>>
Yii框架中ActiveRecord使用Relations
查看>>
leetcode 55.跳跃游戏
查看>>
flexPaper +swftools实现文档在线阅读
查看>>
分形树的绘制
查看>>
loadrunner请求中有汉字 如何编码
查看>>
java数据结构 • 面向对象 • 异常 • 随机数·时间
查看>>
springmvc 实现pc端手机端适配(同一个请求根据不同客户端展示不同界面)
查看>>
BTree和B+Tree详解
查看>>
VS2005工程迁移到Eclipse CDT
查看>>
Linux高端内存映射(上)【转】
查看>>
usb_control_msg参数详解【转】
查看>>
8086汇编指令速查手册
查看>>
j2EE web.xml中的url-pattern的映射规则
查看>>
带输入输出参数的存储过程
查看>>
字符编码简介
查看>>
LevelDB源码之六缓存机制
查看>>
双向链表
查看>>
安装unity3d多个版本共存
查看>>