附加到XML文件内容并汇总XML中的节点数 [英] Append to XML file content and sum the number of nodes in the XML

查看:120
本文介绍了附加到XML文件内容并汇总XML中的节点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击按钮后,生成文件,xml文件将使用现有xml文件中创建的文件更新节点,并总结记录中的所有节点。



如何将节点附加到现有的xml文件中?



我尝试过:



xml文件的内容:



  <?  xml     version   =  1.0   编码  =  utf-8  >  
< root >
< rec >
< totalrec > 3

< datas >
< data >
< id > 000
< 文件 > 20170111000U.TIF
< file > 20170111000R.TIF​​
< / data >
< 数据 >
< ; id > 001
< file > 20170111001U.TIF
< file > 20170111001R.TIF​​
< span class =code-keyword><
/ data >
< 数据 >
< id > 002
< file > 20170111002U.TIF
< file < span class =code-keyword>> 20170111002R.TIF​​
< / data >

解决方案

使用XmlReader阅读现有文件和XmlWriter以创建更新版本。请参阅 System.Xml命名空间 [ ^ ]。

After I click the button, the file is generated, the xml file will update the nodes with those files created in the existing xml file and sum up all the nodes in the records.

How do I append the node into existing xml file?

What I have tried:

Content of xml file:

<?xml version="1.0" encoding="utf-8"?>
<root>
	<rec>
		<totalrec>3
	
	<datas>
		<data>
			<id>000
			<file>20170111000U.TIF
			<file>20170111000R.TIF
		</data>
		<data>
			<id>001
			<file>20170111001U.TIF
			<file>20170111001R.TIF
		</data>
		<data>
			<id>002
			<file>20170111002U.TIF
			<file>20170111002R.TIF
		</data>

解决方案

Use an XmlReader to read the existing file, and an XmlWriter to create the updated version. see System.Xml Namespace[^].


这篇关于附加到XML文件内容并汇总XML中的节点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆