TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sunny S
NA
9
480
How to Check a Particular Element has a Value or elements ?
Oct 13 2019 6:21 AM
How to check a particular Element has a value or inner elements?
here I have a list of Students, by using the name as search key displaying their results to richtextbox but here I have a problem where it comes to smith like students, I have one more table inside it as a list of marks, how to check and display
Do that particular element have value or elements?
I am using C# and LINQ to retrieve the data.
<StudentDataset>
<Student>
<Name>Raj</Name>
<TotalMarks>330</TotalMarks>
<timestamp>2019-09-12T10:22:45.607189+5</timestamp>
</Student>
<Student>
<Name>Shiv</Name>
<TotalMarks>580</TotalMarks>
<timestamp>2019-09:22:45.6071899+2:30</timestamp>
</Student>
<Student>
<Name>Dennis</Name>
<TotalMarks>514</TotalMarks>
<timestamp>2019-09-12T10:2:45.6071899</timestamp>
</Student>
<Student>
<Name>Lisa</Name>
<TotalMarks>510</TotalMarks>
<timestamp>2011-02-12T10:22:45.6071899+1:30</timestamp>
</Student>
<Student>
<Name>Laxmi</Name>
<TotalMarks>380</TotalMarks>
<timestamp>2019-09-12T10:22:45.6071899+05:30</timestamp>
</Student>
<Student>
<Name>Rahul</Name>
<TotalMarks>490</TotalMarks>
<timestamp>2019-09-12T10:22:45.6071899+05:30</timestamp>
</Student>
<Student>
<Name>Smith</Name>
<TotalMarks>
<IndividualScores>
<Table Mode="SSC">
<Item Marks="40" Result="10.6" />
<Item Marks="100" Result="6.4" />
<Item Marks="110" Result="5.7" />
<Item Marks="120" Result="5" />
<Item Marks="130" Result="4.3" />
<Item Marks="140" Result="3.5" />
<Item Marks="150" Result="2.8" />
</Table>
<Table Mode="Inter">
<Item Marks="40" Result="8.8" />
<Item Marks="50" Result="8.8" />
<Item Marks="60" Result="8.8" />
<Item Marks="70" Result="8.8" />
<Item Marks="80" Result="8.8" />
</Table>
</IndividualScores>
</TotalMarks>
<timestamp>2013-01-16T10:40:00.862238-08:00</timestamp>
</Student>
<Student>
<Name>Jessy</Name>
<TotalMarks>540</TotalMarks>
<timestamp>0001-01-01T00:00:00-08:00</timestamp>
</Student>
</StudentDataset>
XDocument doc = XDocument.Load(@"filename");
IEnumerable<XElement> AllStudntElements = doc.Root.Elements();
var SelectDataByName = from element in AllStudntElements
where element.Element("Name").Value == SearchtItem
select element;
using for each loop it is working perfectly for every student but like smith how to check whether total marks have inner elements or not and how to display Marks and Results as a list for smith like students?
I have tried everything like **has children,hasAttribute** but nothing giving proper results?
Reply
Answers (
2
)
row validating not letting form to close if a new row added
Hepl Create Qr code and Export to excel file in c# winform