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:
XML
<hoofdnaam id="58">
        <code>KC</code>
        <omschrijving>kalkschiefer</omschrijving>
        <classificatie>carbonaat gest.</classificatie>
    </hoofdnaam>


I have an xml file and having the above element.

My need is,

to check if
omschrijving
=
kalkschiefer
then
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
Posted
Comments
Sergey Alexandrovich Kryukov 8-Dec-11 2:13am    
Not a question.
--SA

Hi,

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.

C#
XMLDocument objDOM = new XMLDocument();
objDOM.Load(XMLFilePath);
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