?
Solved

Check if a given value exists in an XML file

Posted on 2008-10-23
2
Medium Priority
?
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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:…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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