Solved

Check if a given value exists in an XML file

Posted on 2008-10-23
2
478 Views
Last Modified: 2013-12-17
Hi all,
I have a string value, for example "000057"

I have an XML with different values:
<?xml version="1.0" encoding="utf-8" ?>
<klanten>
      <klant>000051</klant>
      <klant>000052</klant>
      <klant>000053</klant>
      <klant>000054</klant>
      <klant>000055</klant>
      <klant>000056</klant>
      <klant>000057</klant>
      <klant>000058</klant>
      <klant>000059</klant>
      <klant>000060</klant>
      <klant>000061</klant>
</klanten>

How can I determine if the given value is located in the XML, retruning true or false ?
0
Comment
Question by:JamesBrian
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 22784215
Hello JamesBrian,

System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument;
xDoc.Load("MyDoc.xml");
If (xDoc.SelectSingleNode("klanten[klant='000057']") != null) {
  //it exists }
else
 {//it doesn't}

Regards,

TimCottee
0
 

Author Closing Comment

by:JamesBrian
ID: 31509127
Quick and good !
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question