C#中用XmlDocument对象获取XML文件中的节点值

C#:快速读取XML节点内容 xml内容如下: <promotion_coupons_get_response> <tot_results> 200 </tot_results> <coupons list="true"> <coupon> <coupon_id> 123 阅读详情

C#中用XmlDocument对象获取XML文件中的节点值

XmlDocument是表示DOM的类。
1.加载XML文档:使用load()方法加载XML文档;
2.读取节点:使用GetElementById()、getElementsByTagName_r()方法根据ID或标签名读取节点;
3.查找节点:使用SelectSingleNode(string search)方法通过XPath查找节点;
4.插入节点:使用createElement_x()方法创建节点,AppendChild()方法添加新节点;
5.创建文档:通过XmlDeclaration对象新建声明节点,其他同插入节点。
xml文件:
<?xml version="1.0" encoding="utf-8" ?>
<bookstore>
  <book>
    <title lang="eng">Harry Potter</title>
    <price>29.99</price>
  </book>
  <book>
    <title lang="eng">Learning XML</title>
    <price>39.98</price>
  </book>
  <bookstore>
    <title lang="eng">Learning C#</title>
    <price>55.23</price>
  </bookstore>
  <item name="1">第一个item</item>
  <item name="2">
    <item name="1">这个结点(1)</item>
    <item name="2">这个结点(2)</item>
    <book>
      <title lang="cn">Learning C</title>
      <price>60.95</price>
    </book>
  </item>
</bookstore>
           XmlDocument xdoc = new XmlDocument();
            xdoc.Load(Server.MapPath("books.xml"));
            XmlNodeList xnl = xdoc.SelectNodes("/bookstore/book");
            string nodeTempStr = "";
            foreach (XmlNode node in xnl)
            {
                nodeTempStr = node.InnerText;
                node ......


实例:处理books.xml文档

TestXmlDocument.cs:
001.using System;
002.using System.Xml;
003. 
004.namespace Magci.Test.XML.TestXmlDocment
005.{
006.class Program
007.{
008.private static XmlDocument doc;
009. 
010.static void Main(string[] args)
011.{
012.doc = new XmlDocument();
013.//加载XML文档
014.doc.Load(@"..\..\books.xml");
015.DisplayTitle();
016.SearchByTitle("The Gorgias");
017.Insert();
018.CreateDoc();
019. 
020.Console.ReadLine();
021.}
022. 
023.//遍历节点
024.public static void DisplayTitle()
025.{
026.XmlNodeList nodes = doc.getElementsByTagName_r("title");
027.Console.WriteLine("Title:");
028.foreach (XmlNode node in nodes)
029.{
030.Console.WriteLine(node.InnerText);
031.}
032.}
033. 
034.//根据title查找
035.public static void SearchByTitle(string title)
036.{
037.string search = "bookstore/book[title='" + title + "']";
038.XmlNode foundNode = doc.SelectSingleNode(search);
039.Console.WriteLine("\nSearch by title:");
040.if (foundNode != null)
041.{
042.Console.WriteLine(foundNode.InnerText);
043.}
044.else
045.{
046.Console.WriteLine("Not Found!");
047.}
048.}
049. 
050.//插入节点
051.public static void Insert()
052.{
053.//创建book元素
054.XmlElement newBook = doc.createElement_x("book");
055.newBook.SetAttribute("genre", "MyStery");
056.newBook.SetAttribute("publicationdate", "2001");
057.newBook.SetAttribute("ISBN", "123456789");
058. 
059.//创建title元素
060.XmlElement newTitle = doc.createElement_x("title");
061.newTitle.InnerText = "The Case of the Missing Cookie";
062.//将title元素添加到book元素中
063.newBook.AppendChild(newTitle);
064. 
065.XmlElement newAuthor = doc.createElement_x("author");
066.newBook.AppendChild(newAuthor);
067. 
068.XmlElement newName = doc.createElement_x("name");
069.newName.InnerText = "C.Monster";
070.newAuthor.AppendChild(newName);
071. 
072.XmlElement newPrice = doc.createElement_x("price");
073.newPrice.InnerText = "9.99";
074.newBook.AppendChild(newPrice);
075. 
076.//将新建的book元素加入到XML文档中
077.doc.DocumentElement.AppendChild(newBook);
078. 
079.//另存为
080.XmlTextWriter tr = new XmlTextWriter(@"..\..\booksEdit.xml", null);
081.tr.Formatting = Formatting.Indented;
082.doc.WriteContentTo(tr);
083.tr.Close();
084.Console.WriteLine("\nbooksEdit.xml Saved successful.\n");
085. 
086.XmlNodeList nodes = doc.getElementsByTagName_r("title");
087.Console.WriteLine("Display title after Insert:");
088.foreach (XmlNode node in nodes)
089.{
090.Console.WriteLine(node.InnerText);
091.}
092.}
093. 
094.//创建文档
095.public static void CreateDoc()
096.{
097.XmlDocument newDoc = new XmlDocument();
098. 
099.//创建声明节点
100.XmlDeclaration newDec = newDoc.CreateXmlDeclaration("1.0", "utf-8", null);
101.newDoc.AppendChild(newDec);
102. 
103.XmlElement newRoot = newDoc.createElement_x("bookstore");
104.newDoc.AppendChild(newRoot);
105. 
106.XmlElement newBook = newDoc.createElement_x("book");
107.newBook.SetAttribute("genre", "MyStery");
108.newBook.SetAttribute("publicationdate", "2001");
109.newBook.SetAttribute("ISBN", "123456789");
110. 
111.XmlElement newTitle = newDoc.createElement_x("title");
112.newTitle.InnerText = "The Case of the Missing Cookie";
113.newBook.AppendChild(newTitle);
114. 
115.XmlElement newAuthor = newDoc.createElement_x("author");
116.newBook.AppendChild(newAuthor);
117. 
118.XmlElement newName = newDoc.createElement_x("name");
119.newName.InnerText = "C.Monster";
120.newAuthor.AppendChild(newName);
121. 
122.XmlElement newPrice = newDoc.createElement_x("price");
123.newPrice.InnerText = "9.99";
124.newBook.AppendChild(newPrice);
125. 
126.newRoot.AppendChild(newBook);
127. 
128.XmlTextWriter tr = new XmlTextWriter(@"..\..\booksCreate.xml", null);
129.tr.Formatting = Formatting.Indented;
130.newDoc.WriteContentTo(tr);
131.tr.Close();
132.Console.WriteLine("\nbooksCreate.xml Saved successful.\n");
133. 
134.XmlNodeList nodes = newDoc.getElementsByTagName_r("title");
135.Console.WriteLine("Display title after Create:");
136.foreach (XmlNode node in nodes)
137.{
138.Console.WriteLine(node.InnerText);
139.}
140.}
141.}
142.}


books.xml:
01.<?xml version="1.0" encoding="utf-8" ?>
02.<bookstore>
03.<book genre="autobiography" publicationdate="1991" ISBN="1-861003-11-0">
04.<title>The Autobiography of Benjamin Franklin</title>
05.<author>
06.<first-name>Benjamin</first-name>
07.<last-name>Franklin</last-name>
08.</author>
09.<price>8.99</price>
10.</book>
11.<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
12.<title>The Confidence Man</title>
13.<author>
14.<first-name>Herman</first-name>
15.<last-name>Melville</last-name>
16.</author>
17.<price>11.99</price>
18.</book>
19.<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
20.<title>The Gorgias</title>
21.<author>
22.<name>Plato</name>
23.</author>
24.<price>9.99</price>
25.</book>
26.</bookstore>


booksEdit.xml:修改后的XML文档
01.<?xml version="1.0" encoding="utf-8"?>
02.<bookstore>
03.<book genre="autobiography" publicationdate="1991" ISBN="1-861003-11-0">
04.<title>The Autobiography of Benjamin Franklin</title>
05.<author>
06.<first-name>Benjamin</first-name>
07.<last-name>Franklin</last-name>
08.</author>
09.<price>8.99</price>
10.</book>
11.<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
12.<title>The Confidence Man</title>
13.<author>
14.<first-name>Herman</first-name>
15.<last-name>Melville</last-name>
16.</author>
17.<price>11.99</price>
18.</book>
19.<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
20.<title>The Gorgias</title>
21.<author>
22.<name>Plato</name>
23.</author>
24.<price>9.99</price>
25.</book>
26.<book genre="MyStery" publicationdate="2001" ISBN="123456789">
27.<title>The Case of the Missing Cookie</title>
28.<author>
29.<name>C.Monster</name>
30.</author>
31.<price>9.99</price>
32.</book>
33.</bookstore>


booksCreate.xml:新建的XML文档
01.<?xml version="1.0" encoding="utf-8"?>
02.<bookstore>
03.<book genre="MyStery" publicationdate="2001" ISBN="123456789">
04.<title>The Case of the Missing Cookie</title>
05.<author>
06.<name>C.Monster</name>
07.</author>
08.<price>9.99</price>
09.</book>
10.</bookstore>


C#读取xml节点数据  第一种: 使用XPath XML的路径我配置在web.config 的appSettings节点下         XML结构如下: 1111 aa 2222 bb  在C#中,我使用HashTable来进行存储: Hashtable ht = new Hashta 阅读详情

相关推荐

C#开发——使用XmlDocument访问XML文件

XML文件即可扩展标记语言(eXtensible Markup Language)文件,是一种纯文本格式的文件,用于描述和存储数据,使其具有结构性。

weixin_59555766的博客 1737

C#获取指定xml文件的节点数据

/// <summary> /// 获取指定文件的xml的对应key的值 /// </summary> /// <param name="catalogName">目录名</param> /// <param name="fileName">文件名</param> /// <param name="key">键值</param>...

laizhixue的博客 4293

XML文件扩展:如何使用C#追加节点

System.Xml命名空间是.NET框架中处理XML文档的核心组件。它为开发者提供了一系列强大的类和接口,使得在C#中操作XML文档变得简单高效。该命名空间下不仅包括了用于读取、写入、查询和操作XML的API,而且还为XML数据的安全和验证提供了支持。上述代码展示了如何在C#中引用System.Xml命名空间,以便使用其下定义的类和方法。

weixin_33480380的博客 971

查询XML内容中节点的几个常用方法

       对Xml的节点进行简单查询的时候,常用的可以使用如下方法:(1) XmlNode node = doc.SelectSingleNode("//AllNode/Node[@ID = ’aaa’]");在整个Xml中查找AllNode节点下的节点名为Node的节点,该子节点的ID属性值为aaa(2)XmlNode node = doc.SelectSingleN

宁以至远 3393

LeRobot SO-ARM100 学习笔记(2) diffusion module

对 lerobot 中的 diffusion policy 进行基本的代码阅读

mikhailbran的博客 1586

【远控使用】Cobalt Strike横向渗透域控

categories: 知识积累 top: FALSE copyright: true abbrlink: 1643719980 #date: '2021-8-7 12:00:00' #description:1400x780 tags: 内网渗透 提权 渗透测试 黑客工具photos: https://gitee.com/gylq/cloudimages/raw/master/img/image-20210826182104275.png 前言 Cobalt Strike.

孤桜懶契 2704

XML(4)XDocument和XmlDocument搜索指定的节点

XmlDocument StringBuilder str = new StringBuilder(); XmlDocument document = new XmlDocument(); document.Load("List1.xml"); Xm

崔博伦 一路有你 6586

Eclipse在Mac上报错JNI_CreateJavaVM?可能是你的JDK架构搞错了(附Adoptium JDK下载指南)

本文深入解析了Mac(尤其是Apple Silicon芯片)上Eclipse启动时出现“JNI_CreateJavaVM”错误的根本原因,即JDK架构(aarch64与x86_64)不匹配。文章提供了详细的诊断步骤,并推荐通过下载并配置Eclipse Adoptium提供的aarch64版本JDK来彻底解决问题,同时附上清晰的配置指南。

weixin_29065659的博客 321

C#中用XmlDocument对象获取带名命空间XML文件的节点值

xml文件:       Harry Potter    29.99        Learning XML    39.98        Learning C#    55.23    第一个item      这个结点(1)    这个结点(2)          Learning C      60.9

大爱无疆 1990

PX4从放弃到精通(五):PX4中的姿态表示方法及转换关系

文章目录机体坐标系与地理坐标系一、pandas是什么?二、使用步骤1.引入库2.读入数据总结 机体坐标系与地理坐标系 在实际应用中,加速度计的测量轴是由运动平台安装固定此器件的轴向决定的。这些坐标轴就形成了载体坐标系,定义如下: 坐标原点设在载体质心(这样可简化运动方程的推导); y轴指向载体前方,称为横滚轴,横滚角以y轴为起始旋转轴而得到,符合右手定则; x轴与y轴夹角90°,指向载体横向,称为俯仰轴,俯仰角以x轴为起始旋转轴而得到,符合右手定则; z轴与x轴、y轴构成右手笛卡儿坐标系,指向载体垂直方向

超维空间科技的博客 8113

足式机器人全身 MPPI: 利用 MPPI 对足式机器人进行实时全身控制

本研究首次在真实四足机器人上成功部署了基于全身采样的模型预测控制(MPC)系统。采用模型预测路径积分(MPPI)算法,通过并行采样和评估控制轨迹实现实时运动规划。该系统能处理复杂接触场景,完成推箱子、爬越障碍及崎岖地形行走等任务。实验使用Unitree Go1机器人,结合MuJoCo仿真器快速生成运动策略,仅需简单控制策略即可实现稳健操作。硬件验证表明,该方法能有效完成目标导向的箱子推动任务。该成果标志着采样MPC在足式机器人实际应用中的重要突破。

2506_90492529的博客 999

C#中XmlDocument读取和创建 XML 文档

系列文章目录 C#处理XML 数据的技术方法总结 XmlDocument读取和创建 XML 文档 XmlWriter类提供一种快速非缓存的只进 XML 数据生成方式 XmlReader类提供一种快速非缓存的只进 XML 数据访问方式 LINQ to XML用于访问 XML 数据 XPathNavigator类对XmlDocument和XPathDocument中的 XML 提供多个编辑选项和导航功能 XslCompiledTransform类为使用 XSL 转换进行 XML 数...

兽神 3557

DeerFlow 系列教程 第十八篇 | 实战案例三——用 DeerFlow 构建自定义 AI 工作流

在实际业务中,许多复杂的内容生产任务不是单一技能就能覆盖的。需要先调研某个主题的最新信息基于调研结果撰写结构化的文章或报告对报告中的数据进行可视化处理最终输出符合品牌风格的排版文档或演示文稿这些环节涉及不同的领域知识和工具链,单个内置技能无法完全覆盖。组合自定义技能、MCP 外部工具和多 Agent 协作,构建端到端的工作流。传统手工流程: DeerFlow 自定义工作流:搜索资料、阅读文献 用户描述需求│ │▼ ▼。

weixin_43674738的博客 204

【C#】创建、解析 xml 文件(XmlDocument 方式)

前言 本文使用 System.Xml 中的 XmlDocument 解析 xml 格式的文件。另外,由于我是粗略的看了下官方文档和一些博客,可能会有许多错误的地方,望指出。 官方文档:https://docs.microsoft.com/zh-cn/dotnet/api/system.xml.xmldocument?view=netframework-4.8 文章时间: 写于 2019-7-17...

zzy0006的博客 9583

RKNN 端侧部署必看:YOLOv11 Pose 姿态估计模型转换与性能优化实战

随着人工智能技术在边缘计算领域的快速发展,姿态估计作为计算机视觉的重要分支,在智能监控、人机交互、体感游戏等场景中展现出巨大的应用潜力。本文深入研究了YOLOv11 Pose模型在Rockchip RKNN平台上的部署方案,从理论基础、模型转换、平台优化到实际部署进行了全面阐述。通过详细的技术分析和实验验证,证明了RKNN平台能够有效提升YOLOv11 Pose的推理性能,在RK3588硬件平台上实现了高达100 FPS的实时姿态检测,为边缘计算场景下的姿态估计应用提供了高效的解决方案。

m0_71589036的博客 183

国密SSL通信的调试技巧

前面写了几篇国密开发相关的文章:解读国密非对称加密算法SM2啥?双证书?详解国密SM2的加密和解密详解国密SSL ECC_SM4_SM3套件详解国密SM2的数字签名这篇文章来聊一聊国密S...

云水木石 3206

C#中读取xml文件指定节点

参考:Select XML Nodes by Name假设xml文件内容是1start1112pass22

xwdreamer的专栏 4万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

C# 读取xml文件中节点和子节点的值

private void ReadXml() { XmlDocument doc = new XmlDocument(); //Resources文件夹下加载xml doc.LoadXml(Properties.Resources.XML文件名); //获得根节点 ...

qq_42391680的博客 9005

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

C# XML文件的一些操作(XmlDocument、XmlElement、XmlNode)

C#操作xml主要有这么几个对象:XmlDocument、XmlElement、XmlNode 命名空间: using System.Xml; 知识补充: XmlNode和XmlElement的区别: 1、Element是一个小范围的定义,必须含有完整信息的节点才能叫做元素。 2、Node是基本对象,Attribute、Element、Text等都是Node的子对象。 一个元素一定是

白永辉的专栏 4万+

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

C# 操作XML文件 XmlDocument和XElement

首先在根目录下新建一个config.xml: <?xml version="1.0" encoding="utf-8"?> <Config> <Debug> <Lan> <Server Ip="142.12.10.123" Port="9601"/> </Lan&g...

Stay Hungry 4083

C# 使用XmlDocument类读取XML文件

经过3天的测试验证发现使用XmlDocument读取XML文件的各个节点的值很容易实现。测试XML文件如下 products.xml:<Table> <Product> <Product_id>1</Product_id> <Product_name>Product 1</Product_name> <Product_price>1000</Product_price> </Product> &

flysh05的专栏 3715

c#获取xml对应节点属性及节点内容

本文介绍了使用XmlDocument如何获取对应节点对应的属性值以及节点内容: 下面展示一些 内联代码片。 // A code block var foo = 'bar'; XmlDocument xml = new XmlDocument();//实例化这个类 string path = @"文件"; xml.Load(path); string xmltxt = xm

weixin_44172770的博客 5145

.Net那点事儿系列:C#操作Xml:通过XmlDocument读写Xml文档

.Net那点事儿系列:C#操作Xml什么是Xml?Xml是扩展标记语言的简写,是一种开发的文本格式。关于它的更多情况可以通过w3组织了解http://www.w3.org/TR/1998/REC-xml-19980210。如果你不知道它,那你就out太多了。.Net是如何处理Xm

玉开的技术博客 6807

C# 获取XML中所有节点值

C# 获取XML中所有节点值 考虑写一些操作XML的公共方法生成dll,以备以后经常使用,今天先实现了获取XML中所有节点值。 参考资料: shmiloy001的博客 : http://blog.youkuaiyun.com/shmiloy001/article/details/6637686 稍作修改,可以作为dll引用,代码如下: using...

weixin_30745641的博客 953

C#修改XML节点的值

XmlDocument MyXml = new XmlDocument();            MyXml.Load(@"Config.xml");             //获取节点的所有子节点            XmlNodeList MyNodeList = MyXml.SelectSingleNode("Rule").ChildNodes;             //遍

leelong80的专栏 7937
上一篇: 只选中GridView中的一个CheckBox
下一篇: 拼接的字符串导入EXCEL
wanglei_samrtfish
博客等级 码龄15年 38粉丝 137原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值