在xml文件vb .net中写入和替换值 [英] write and replace value in xml file vb .net
本文介绍了在xml文件vb .net中写入和替换值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我已经在我的项目中插入了一个xml文件,并希望将其值,一个整数,更新为1,如果值为1则变为2等等。读取和写入xml文件?
Hello,
I have inserted in my project an xml file and want to have it's value, an integer, to be updated by 1, if the value is 1 to become 2 etc. how to read and write to xml file?
<?xml version="1.0" encoding="utf-8" ?>
<Person>
<id>1</id>
</Person>
xml结构
the xml structure
a=a+1
vb更新值
我不想保留记录只想删除xml中的旧值并替换为新值
the vb update value
I don't want to keep a record just want to delete old value in xml and replace with new value
推荐答案
您需要一个不同的概念。
XML文件只是一个对象的序列化版本,在你的情况下是一个对象类型为Person的对象,其属性为1.
现在你需要那个Person类,具有从XML文件创建Person对象的函数,以及将其数据写回XML文件的函数。
You need a different concept.
The XML file is only a serialized version of an object, in your case an object of type Person with the id-Property of 1.
Now you need that Person class, with a function to create a Person object from an XML file, and a function to write its data back to an XML file.
这篇关于在xml文件vb .net中写入和替换值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文