使用C#检查Xml文件中是否已存在元素和属性值 [英] Checking the element and attributes values already exists in Xml file using C#

查看:691
本文介绍了使用C#检查Xml文件中是否已存在元素和属性值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

任何人都可以指导我一个想法.

iam从C#创建XML文件.
我有一个带有一些文本框和Button的窗口,用于创建xml文件.

我在文本框中输入一些数据,然后单击创建xml文件的按钮.
如果文件存在,则将数据追加到现有文件.

在这里,如果输入相同的数据,我不想将数据附加到xml.就我而言,它也要附加相同的数据.

所以请让我知道如何检查输入的元素和属性值是否已经存在于xml文件中.如果存在,我不想添加数据,否则将数据添加到xml文件.

谢谢,

Hello,

Can any one guide me with a idea.

iam creating a XML file from C#.
I have a window with some textboxes and Button to create xml file.

i enter some data in textboxes and click on button which creates xml file.
if the file alredy exists iam appending data to the existing file.

here if the enter the same data i dont want to append the data to the xml. in my case it is appending the same data also.

so plz give me idea how can i check if the element and attribute values which i enter already exits in the xml file. if exists i dont want to add the data otherwise add the data to the xml file.

thanks,

推荐答案

您需要形成并 XPath [^ ]查询以检查现有数据.链接中有很多示例
You would need to form and XPath[^] query to check for existing data. There are many examples in the link


这篇关于使用C#检查Xml文件中是否已存在元素和属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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