XmlDocument.LoadXml和Load的区别
LoadXml:从指定的字符串加载 XML 文档。
eg:doc.LoadXml("<root>aa</root>");
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
public void LoadXmlTest() {
// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>");
// Add a price element.
XmlElement newElem = doc.CreateElement("price");
newElem.InnerText = "10.95";
doc.DocumentElement.AppendChild(newElem);
XmlNode xmlNode = doc.SelectSingleNode("/item/name");
Console.WriteLine(xmlNode.InnerText);
xmlNode = doc.SelectSingleNode("/item/price");
Console.WriteLine(xmlNode.InnerText);
// Save the document to a file and auto-indent the output.
XmlTextWriter writer = new XmlTextWriter("data.xml", null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
}
// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>"); // Add a price element.
XmlElement newElem = doc.CreateElement("price");
newElem.InnerText = "10.95";
doc.DocumentElement.AppendChild(newElem); XmlNode xmlNode = doc.SelectSingleNode("/item/name");
Console.WriteLine(xmlNode.InnerText);
xmlNode = doc.SelectSingleNode("/item/price");
Console.WriteLine(xmlNode.InnerText); // Save the document to a file and auto-indent the output.
XmlTextWriter writer = new XmlTextWriter("data.xml", null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
}
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
Load:加载指定的 XML 数据
XmlDocument.Load (Stream)从指定的流加载 XML 文档。
XmlDocument.Load (String) 从指定的 URL 加载 XML 文档。
XmlDocument.Load (TextReader) 从指定的 TextReader 加载 XML 文档。
XmlDocument.Load (XmlReader)从指定的 XmlReader 加载 XML 文档。
public void getInfo(string fileName)
{
//创建XML的根节点
// CreateXMLElement();
string fileFullPath = Application.StartupPath + "\\" + fileName;
Console.WriteLine(fileFullPath);
XmlDocument doc = new XmlDocument();
doc.Load(fileFullPath); XmlNodeList xmlNodeList = doc.SelectNodes("/root/business/item");
foreach (XmlNode xmlNode in xmlNodeList)
{
Console.WriteLine(string.Format("{0}\t{1} \n{2}", xmlNode.Attributes["BusinessName"].Value, xmlNode.Attributes["DistinctionKey"].Value, xmlNode.Attributes["Url"].Value));
} Console.ReadLine();
}
http://msdn.microsoft.com/zh-cn/library/system.xml.xmldocument.loadxml(VS.80).aspx
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
XmlDocument.LoadXml和Load的区别的更多相关文章
- Hibernate中session.get()和session.load()的区别
-- 翻译自https://www.mkyong.com/hibernate/different-between-session-get-and-session-load/ 很多时候你会发现,使用Hi ...
- Get和Load的区别----hibernate
Get和Load的区别
- Hibernate的Session的get()和load()方法区别
hibernate中Session接口提供的get()和load()方法都是用来获取一个实体对象,在使用方式和查询性能上有一些区别. get Session接口提供了4个重载的get方法,分别通过“持 ...
- 【转载】DOMContentLoaded与load的区别
DOMContentLoaded与load的区别 (1)在chrome浏览器的开发过程中,我们会看到network面板中有这两个数值,分别对应网 络请求上的标志线,这两个时间数值分别代表什么? ( ...
- ready与load的区别
JQuery里有ready和load事件 $(document).ready(function() { // ...代码... }) //document ready 简写 $(function() ...
- hibernate延迟加载(get和load的区别)
概要: 在hibernate中我们知道如果要从数据库中得到一个对象,通常有两种方式,一种是通过session.get()方法,另一种就是通过session.load()方法,然后其实这两种方法在获得一 ...
- jQuery document window load ready 区别详解
用过JavaScript的童鞋,应该知道window对象和document对象,也应该听说过load事件和ready事件,小菜当然也知道,而且自认为很了解,直到最近出了问题,才知道事情并不是那么简单. ...
- body里面的onload和window.onload,window.load的区别
区别:body里面的onload是在“页面加载完成后执行的动作”window里面的onload是在“页面加载时执行的动作” window.load这个应该只是表明事件方法,但并未执行,比如click表 ...
- Hibernate中get()和load()方法区别
get和load方式是根据id取得一个记录下边详细说一下get和load的不同,因为有些时候为了对比也会把find加进来. 1.从返回结果上对比:load方式检索不到的话会抛出org.hibernat ...
随机推荐
- asp.net mvc部分视图的action中获取父级视图信息
RouteData.DataTokens["ParentActionViewContext"]中包含了父级视图的相关信息,如路由等 public ActionResult Chil ...
- 原生 javaScript 百叶窗 效果的实现及原理介绍
百叶窗大家都见过吧!如图: 原理: 如图所示,空心格子就好比是每个li,给它设定相对定位属性,设置overflow:hidden: 黑块为li子元素,高度为li的2倍,设置absolute属性,我们正 ...
- 在线编辑器Ckeditor (2) - php (31)
接上一篇 3 in-page(页内)配置,在使用Ckeditor的界面里进行直接配置 页内配置 效果 特点:配置项完全属于某个特定的Ckeditor实例,不可重用 三种配置方式比较 定制方式 特点 说 ...
- 深入了解java虚拟机(JVM) 第七章 内存分配策略
理解了jvm内存分配策略不仅是程序性能调优的重要知识,还能够给养成自己一种良好的代码思路,一个程序的代码差异往往都是在这里体现出来的. 一.对象优先分配到Eden区域 一般来说,新创建的对象都会直 ...
- 【OCP-052】052最新考试题库分析整理-第7题
7.Which is true about external tables? A) The ORACLE_DATAPUMP access driver can be used to write dat ...
- “全栈2019”Java异常第三章:try代码块作用域详解
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java异 ...
- java.lang.IncompatibleClassChangeError:可以考虑是否是jar包冲突
一.背景:启动tomcat的时候,报错: java.lang.IncompatibleClassChangeError: class org.springframework.core.type.cla ...
- [Objective-C语言教程]类和对象(24)
Objective-C编程语言的主要目的是为C编程语言添加面向对象,类是Objective-C的核心特性,支持面向对象编程,通常称为用户定义类型. 类用于指定对象的形式,它将数据表示和方法组合在一起, ...
- Linux 服务器加入Windows AD
背景信息: Windows AD Version: Windows Server 2012 R2 zh-cn 计算机全名:hlm12r2n1.hlm.com 域:hlm.com 域控管理员:stone ...
- Asp.net的生命周期应用之IHttpHandler
摘自:http://www.cnblogs.com/JimmyZhang/archive/2007/09/15/894124.html Framework提供了一系列的接口和类,允许你对于Http请求 ...