Bytech India
asked on
I want to do searching on the basis of first and third character i.e. a*d using LINQ from an xml file.How should i do it?
Dear All
I have an XML file in which I am searching city's on the basis of filter containing first three characters,which is working fine.
Locations = from data in doc.Root.Elements(rs + "data")
// Get access to the child nodes using the XNamespace z
from city in data.Elements(z + "row").Attributes("CITY")
// Filter the result set
where city.Value.StartsWith(subs tr)
select city;
Now I want to do searching on the basis of only first and third character,second character can be anything.
How should I do it?
I have an XML file in which I am searching city's on the basis of filter containing first three characters,which is working fine.
Locations = from data in doc.Root.Elements(rs + "data")
// Get access to the child nodes using the XNamespace z
from city in data.Elements(z + "row").Attributes("CITY")
// Filter the result set
where city.Value.StartsWith(subs
select city;
Now I want to do searching on the basis of only first and third character,second character can be anything.
How should I do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Its working perfectly.Can I check two attributes too using same LINQ query i.e. state is Delhi and city starts with filter?If yes,please explain.
ASKER
Thank you sir.
I did it as below and succeeded.
IEnumerable<XElement> Region = from data in doc.Root.Elements(rs + "data")
from el in data.Elements(z + "row")
where el.Attribute("REGION_NAME" ).Value == State
select el;
Locations = from city in Region.Attributes("CITY")
where city.Value.StartsWith(Filt er)
select city;
I did it as below and succeeded.
IEnumerable<XElement> Region = from data in doc.Root.Elements(rs + "data")
from el in data.Elements(z + "row")
where el.Attribute("REGION_NAME"
select el;
Locations = from city in Region.Attributes("CITY")
where city.Value.StartsWith(Filt
select city;
ASKER
Thank you sir,I will try this.