壮心未与年俱老,死去犹能作鬼雄。这篇文章主要讲述read appSettings in configuration file by XElement with xmlns相关的知识,希望能为你提供帮助。
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/how-to-write-queries-on-xml-in-namespaces
public static int GetProgramId(string filePath) { int programId = 0; var element = XElement.Load(filePath); XNamespace xNamespace = element.GetDefaultNamespace(); XName tempXName1 = xNamespace + "appSettings"; var temp = element.Element(tempXName1); XName tempXName2 = xNamespace + "add"; var targetElement = temp?.Elements(tempXName2) .FirstOrDefault(x => x.Attribute("key")?.Value =https://www.songbingjia.com/android/="ProgramID"); if (targetElement == null) { LogUtil.CreateLog(LogLevel.Error, $"Can not find ProgramID in appSettings section in {filePath}"); } else { var valueAttribute = targetElement.Attribute("value"); if (valueAttribute == null) { LogUtil.CreateLog(LogLevel.Error, $"Can not find value attribute in appSettings section with key = ProgramID in {filePath}"); } else { programId = Convert.ToInt32(valueAttribute.Value); } }return programId; }
【read appSettings in configuration file by XElement with xmlns】
推荐阅读
- 农行掌上银行app下载|农行掌上银行app安卓版下载
- App Store兼容性问题
- SpringBoot 中常用注解@PathVaribale/@RequestParam/@GetMapping介绍
- 快看漫画下载|快看漫画app下载
- 同花顺下载|同花顺app免费下载
- web application firewalld (WAF) 功能
- Mac环境下使用Appium Inspector进行元素定位
- Android app:transformNativeLibsWithStripDebugSymbolForDebug错误分析
- 伴生类和伴生对象(apply方法的实践)