Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
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)
Posted
Updated 11-Feb-14 6:37am
v2

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