Link to home
Start Free TrialLog in
Avatar of Bytech India
Bytech India

asked on

LINQ for reading an XML file

Dear All

Using LINQ,I wanted to search all the cities starting with specific series of characters from the attached sample XML  file format.
I am completly new to LINQ.
I am using following lines for the extraction,.but facing some issue.Please help.

***************************************************************************************
var Locations = from city in doc.Root.Elements("row").Attributes("CITY")
                                where city.Value.StartsWith(Filter)
                                select city;
***************************************************************************************

Thanks in advance.
Sample.xml
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

which issus?
Avatar of Bytech India
Bytech India

ASKER

Sir,instead of array of city in Locations variable I am getting System.Linq.Enumerable+WhereEnumerableIterator`1[System.Xml.Linq.XAttribute].
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much sir.. It worked.. Thanks a lot...
I've requested that this question be closed as follows:

Accepted answer: 0 points for BYTECHINDIA's comment #a40387987

for the following reason:

I applied the code and it worked.. Thats great..
Hi BYTECHINDIA;

Did you mean that you applied the code I posted and it worked? If that is the case you selected the wrong solution as the accepted solution and please have the question re-open so that you may select the correct answer.

Thanks.
I want to reopen this question just because I think by mistake I have accepted the wrong answer as solution.