Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parsing data using XDocument yield no result -Why?
- <!--Sample Person Data-->
- <Person>
- <PersonDetail PersonId="1">
- <Name>Priyanka Das</Name>
- <Age>30</Age>
- <Sex>Male</Sex>
- <LivesIn>Bangalore</LivesIn>
- <Email>nb@training.com</Email>
- </PersonDetail>
- <PersonDetail PersonId="2">
- <Name>Shashidhar Nikatani</Name>
- <Age>40</Age>
- <Sex>Male</Sex>
- <LivesIn>Bangalore</LivesIn>
- <Email>sn@training.com</Email>
- </PersonDetail>
- <PersonDetail PersonId="3">
- <Name>Arundhuti Roy</Name>
- <Age>27</Age>
- <Sex>Female</Sex>
- <LivesIn>Kerala</LivesIn>
- <Email>ab@training.com</Email>
- </PersonDetail>
- <PersonDetail PersonId="4">
- <Name>Nitin Mallik</Name>
- <Age>28</Age>
- <Sex>Male</Sex>
- <LivesIn>Bangalore</LivesIn>
- <Email>ng@training.com</Email>
- </PersonDetail>
- <PersonDetail PersonId="5">
- <Name>Essaki Raja Kandaswamy</Name>
- <Age>27</Age>
- <Sex>Male</Sex>
- <LivesIn>Madras</LivesIn>
- <Email>er@training.com</Email>
- </PersonDetail>
- </Person>
- XDocument xmlSource = null;
- xmlSource = XDocument.Load(@"D:Personsample.xml");
- var query = from data in xmlSource.Descendants("Person")
- where (string)data.Element("LivesIn") == "Bangalore"
- select data;
- from data in xmlSource.Descendants("PersonDetail")
- where (string)data.Element("LivesIn") == "Bangalore"
- select data;
Add Comment
Please, Sign In to add comment