Solved

Check if a given value exists in an XML file

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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