Solved

Check if a given value exists in an XML file

Posted on 2008-10-23
2
475 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now