Click here to Skip to main content
15,908,768 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
<hoofdnaam id="58">
        <classificatie>carbonaat gest.</classificatie>

I have an xml file and having the above element.

My need is,

to check if
i want to select the 'code' correponding tho that block ie, KC here

i have 10 number of block in same xml(10 number of 'hoofdnaam' element)

i am using XDocument

Please help me
Sergey Alexandrovich Kryukov 8-Dec-11 2:13am    
Not a question.


You could always make use of LINQ to XML:

LINQ to XML[^]

Additionally, here is a list of LINQ querying examples: LINQ - Restriction Operators[^] - because you would solve your problem / question by making use of a simple LINQ query.

Another LINQ to XML tutorial: Understanding C#: Simple LINQ to XML examples (tutorial)[^]

Kind regards,
Share this answer
You can use XMLDocument.

XMLDocument objDOM = new XMLDocument();
XmlNodeList XNlist =objDOM.getElementByTagName("hoofdnaam");
for each(XMLNode in XNlist.Nodes)
   if(XMLNode.Name == "code")
      MessageBox.Show(XMLNode.Name); //here you get the code value like KC
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900