mahesh kumar B M

mahesh kumar B M

  • NA
  • 44
  • 1.1m

linq and xml query in vb.net

Feb 11 2014 1:16 PM

Dim contact As XElement = <search Name= "seacrhcontact" id="Mycontact" > <seacrhfieled Name="FirstName" Age="20" place="blor"  company="accentre"/>  <seacrhfieled Name="LastName" Age="30" place="mumbai" company="acc1"/> <seacrhfieled Name="surName" Age="40" place="chennai"  company="hyd"/>   <seacrhfieled Name="MIddleName" Age="50" place="kerla"  company="robo"/>   <seacrhfieled Name="preName" Age="60" place="kolkota"  company="mary"/>   </contact>


Im using the above xml in my program and my program uses a list of Fields. This fields contain 2 attributes or properties
Say field.name and field.value.
 
List of Field objects :

 Properties: field.name and field.value   Dim fld as new list(of fields)   Fld as sample values  like below: Fld.name= "FirstName" Fld.value="Mahesh",

Now I want to see is there any attribute present in xml matching the fld.name attribute of inputr xml.
 
I can write the query like :

Dim test FUNC<XELEMENT,boolean > = function (w) fld.any(function (x) x.name=(w.attribute("seacrhfieled").value))


For example: if my list of fields contains say fld.name as "FirstName" , then it should return true as output.
 
I tried the above code in vb.net but was not able to find the proper solution. Please provide the equivalent code in vb.net and please explain how to debug these linq expressions as we cannot able to see what value is there at variables say function (W)