Imagine we have the following file, saved in c:\contacts.xml
Then we can access it as follows
Notice:
- on an XDocument, we can call descendants and pass it an element name, to get all the elements with that name (we can also call the no-args version, and get all descendants)
- What we're getting is an XElement, on which we can call methods like Element or Attribute
- We can directly cast an element into a string, and it gets us all the text inside that element
- We can cast an attribute as a string, or an int (or even a float, double or many other types)
No comments:
Post a Comment