c# - Reading only the first record from an XML file -
i have xml file "books.xml" follows (the 1st record of books.xml):
<book id="bk101"> <author>gambardella, matthew</author> <title>xml developer's guide</title> <genre>computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description>an in-depth @ creating applications xml.</description>
i want store names of individual tags e.g author,title etc in array of strings. purpose, want read first record books.xml. how can so?
since need first descendant can use this:
var thefirstbook=xdocument.load("books.xml").descendants("book").first();
you're loading xml file in xdocument object, getting descendants of specific tag (book), , getting first of descendants.
Comments
Post a Comment