当前位置:首页 > Windows程序 > 正文

XNode getChildNode = e = (e.NodeType == XmlNodeType.Element

2024-03-31 Windows程序

public static XElement WithoutNamespaces(this XElement element) { if (element == null) return null; #region delegates: Func<XNode, XNode> getChildNode = e => (e.NodeType == XmlNodeType.Element) ? (e as XElement).WithoutNamespaces() : e; Func<XElement, IEnumerable<XAttribute>> getAttributes = e => (e.HasAttributes) ? e.Attributes() .Where(a => !a.IsNamespaceDeclaration) .Select(a => new XAttribute(a.Name.LocalName, a.Value)) : Enumerable.Empty<XAttribute>(); #endregion return new XElement(element.Name.LocalName, element.Nodes().Select(getChildNode), getAttributes(element)); }

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/34107.html

Jm-杰米博客Jamie
草根站长的技术交流乐园!IT不会不要紧快来好好学习吧!
  • 20786文章总数
  • 7494588访问次数
  • 建站天数
  • 友情链接