惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - riancy

XAMPP设置tomcat自启动时,报无效的Win32程序 Centos安装man功能 wmware 10 升级到11后,macos不能运行的问题 Android Sdk Manager更新 Android代码调试报错 可以用来求急的开源项目es5-shim PhoneGap3.2安装步骤 jQuery1.9.1针对checkbox的调整 WPF DataGrid 对行中单元格的访问 Eclipse+JBoss+Seam我实在难以忍受 [jQuery插件开发][dynamicTable2.0]根据JSON数据自动生成HTML Table 根据JSON数据,自动生成Table Jquery插件Uploadify修改应用 Silverlight中的WatermarkedTextBox OutLook的网页版精美界面--修改版 永别了,Text与NText .Net Framework2.0内部版本问题引起的错误! frame间的层级调用,如何支持firefox 可以遗忘的HTML
从XmlDocument到XDocument的转换
riancy · 2010-03-31 · via 博客园 - riancy

扩展XmlDocument

public static class XmlDocumentExtensions
{
 
public static XDocument ToXDocument(this XmlDocument document)
  {
   
return document.ToXDocument(LoadOptions.None);
  }
public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
  {
   
using (XmlNodeReader reader = new XmlNodeReader(document))
    {
     
return XDocument.Load(reader, options);
    }
  }
}

使用例子

XmlDocument doc = new XmlDocument();
doc.LoadXml(
"<parent><child>text</child></parent>");

XDocument
xdoc = doc.ToXDocument();
var children = xdoc.Document.Element("parent").Elements("child");
foreach (var child in children)
{
 
Console.WriteLine(child.Value);
}