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
darma teja
NA
496
336.4k
How to put xpath in xdocument
Apr 5 2013 6:11 AM
Hi All,
my xml file is like this:
<bookstore>
<book category="COOKING">
<title id="1">Everyday Italian</title>
</book>
<book category="CHILDREN">
<title
id="2"
>Harry Potter</title>
</book>
<book category="WEB">
<title
id="3"
>Learning XML</title>
</book>
</bookstore>
I would like to count how many titles in my xml file. for this I used code like this: and It works fine.
var count = XDocument.Load(path).
XPathSelectElements("//
title
").Count();
It means that it goes to each tag and counts. No I do not want o give more burden on my tool. just use the xpath query to get last title id value.
I tried like this. But it is giving me exception.
var count = XDocument.Load(path).XPathSelectElement("
title
[last()]/@id").Value;
Thanks,
Darma
Reply
Answers (
1
)
calculating the percentage of completion of a process
how to use fileuploader in mvc4 with razor view