is it possible to detect if an xml node is present using c#? -


i have xml file , want know if possible see if <vertrekvertragingtekst> present in xml file.

this xml node:

<vertrekkendetrein> <ritnummer>4722</ritnummer> <vertrektijd>2014-06-03t09:45:00+0200</vertrektijd> <vertrekvertraging>pt2m</vertrekvertraging> <vertrekvertragingtekst>+2 min</vertrekvertragingtekst> <eindbestemming>uitgeest</eindbestemming> <treinsoort>sprinter</treinsoort> <vervoerder>ns</vervoerder> <vertrekspoor wijziging="false">2</vertrekspoor> </vertrekkendetrein> 

(these nodes in dutch dont pay attention say, not important)

this c# code have far:

xmlnodelist nodelist = xmldoc.selectnodes("actuelevertrektijden/vertrekkendetrein/*"); foreach (xmlnode nodelist2 in nodelist) {                         if (i < 1) //1         switch (nodelist2.name)         {             case "vertrektijd": string kuttijd1 = (nodelist2.innertext);                 var res1 = regex.match(kuttijd1, @"\d{1,2}:\d{1,2}").value;                 lblv1.text = convert.tostring(res1); break;             case "vertrekvertragingtekst": ververt1.text = (nodelist2.innertext); ververt1.visible = true; vertpic1.visible = true; logo1.top -= 9; lblts1.top -= 9; break;             case "eindbestemming": string vertrek1 = (nodelist2.innertext); if (vertrek1 == "uitgeest") { lblvia1.text = "krommenie-ass"; } lblbs1.text = vertrek1; break;             case "treinsoort": lblts1.text = (nodelist2.innertext); break;             case "routetekst": lblvia1.text = (nodelist2.innertext); break;             case "vertrekspoor": lbls1.text = (nodelist2.innertext); i++; break;         } } 

i can read out of file , works want know how can detect presence of node?

use selectsinglenode method

var result = node.selectsinglenode("nodetocheck"); if(result!=null) { } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -