473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to do verification in XML with C#?

Hello, I currently working on a project where I need to insert a record into XML. I able to insert without problem. But I wonder how to varify do the same client name already exist? If yes, i want to ignore the insertion.

Expand|Select|Wrap|Line Numbers
  1. private void button3_Click(object sender, EventArgs e)
  2.         {
  3.             string FileName = ".\\MasterXml.xml";
  4.  
  5.             XmlTextReader reader = new XmlTextReader(FileName);
  6.             XmlDocument doc = new XmlDocument();
  7.             doc.Load(reader);
  8.             reader.Close();
  9.             XmlNode currNode;
  10.  
  11.             strFileName = ".//" + textBox1.Text + ".xml";
  12.  
  13.             XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
  14.  
  15.             docFrag.InnerXml = "<Client>" + textBox1.Text + "</Client>" +
  16.                 "<XmlPath>" + strFileName.ToString() + "</XmlPath>";
  17.  
  18.             // insert the availability node into the document 
  19.             currNode = doc.DocumentElement;
  20.             currNode.InsertAfter(docFrag, currNode.LastChild);
  21.             //save the output to a file 
  22.             doc.Save(FileName);
  23.  
  24.             XmlTextWriter textWriter2 = new XmlTextWriter(strFileName.ToString(), null);
  25.             textWriter2.WriteStartDocument();
  26.             textWriter2.WriteStartElement("Report");
  27.             textWriter2.WriteStartElement("Client");
  28.             textWriter2.WriteValue(textBox1.Text);
  29.             textWriter2.WriteEndElement();
  30.  
  31.             textWriter2.Close();
  32.         }
  33.  
Oct 8 '10 #1
1 1407
jkmyoung
2,057 Expert 2GB
Find a Client node with the same client.

if (doc.SelectNodes("//Client[.=" + textBox1.Text + "]") == null){
insert (insert code) here
}
Oct 15 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nel | last post by:
I have recently updated an on-line petition at www.fuelprotest.com The confirmation email contained a verification link like...
6
by: Nel | last post by:
I have recently updated an on-line petition at www.fuelprotest.com The confirmation email contained a verification link like...
7
by: SOR | last post by:
Although this currently defeats the spam bots in some respects - isnt it just a mater of time before the spammers figure out a way to verify a signup via email using rotating disposable email...
0
by: pwilliams | last post by:
NCOALink Change of Address Verification Each year over 40 million Americans change their mailing addresses. This change is equivalent to every person in California deciding to change addresses...
13
by: Kal | last post by:
I have a small console app that started out in dotnet 1.1 in VS 2003. That version can be copied to a W2K3 server where it runs fine. I set up a new project in VS 2005 and copied the code files...
3
by: Jano | last post by:
Hi - Happy New Year! I have a web-site which accepted paypal payment for membership. No-one's buying so I want to make it free. The page which inputs the member details into the database needs...
3
by: KDawg44 | last post by:
Hi, I would like a verification image for new sign ups on a website. Is there a way to call the PHP script through an AJAX call and have the image passed back and then display? Is there a way...
15
by: sb5309 | last post by:
When one uses CAPTCHA (form with verification code), a session is required to keep the session data. In examples that I have seen on the net, I did not see a session is closed after use. ...
4
by: sangam56 | last post by:
I have used cookieless mode of ASPState sql server session mode. I have used the CreateUserWizard to register user in the web site. And users must click the email verification link before being...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.