RawBitz (1) [Avatar] Offline
#1
I'm reading chapter 10, LInq to Xml Axis Methods, and I am wondering if you mean "access" instead of "axis". I have many years of programming experience, and try to keep up with new technologies (such as Linq), but I have never heard of "axis methods". Just curious. Thanks.
steve.eichert (22) [Avatar] Offline
#2
Re: You really mean "Access" methods don't you?
Hey Kirk,

The name for the methods discussed in chapter 10 is correct in the book, the methods are axis methods not access methods. An axis defines a node-set relative to the current node. The axis methods allow you to retrieve a particular node-set of interest via the corresponding method. In the book we do group Element() and Attribute() with the other axis methods, and since they don't return a node set they aren't really axis methods. However, since they are so closely related we included them in the axis methods section as well.

If you want to read a little more about LINQ to XML Axes you can checkout this MSDN overview:

http://msdn2.microsoft.com/en-us/library/bb387099.aspx

Cheers,
Steve
jwooley (123) [Avatar] Offline
#3
Re: You really mean "Access" methods don't you?
Actually, it is Axis. See the following link on MSDN: http://msdn2.microsoft.com/en-us/library/bb384769.aspx. Although it does involve accessing related data, that data can be conceptualized as a relationship where the selected element node is the hub and the surrounding portion, including Attributes, child Elements, Parent element, Ancestor elements, Decendents, and sibling ElementsAfterSelf or NodesAfterSelf. The axis methods are methods to navigate around the document.

Consider the following document:
Dim parent = <root name="foo">
<child>
<grandchild>item</grandchild>
<grandchild>sibling</grandchild>
</child>
</root>

You could navigate around it as follows:
dim rootName = parent.Element("child").Descendants("grandchild").First.ElementsAfterSelf().First.Ancestors("child").First.Parent.Attribute("name")

Alternatively, using XML Literals in VB you could state this as follows:
dim rootName = parent.<child>...<grandchild>.First.ElementsAfterSelf().First.Ancestors("child").First.Parent.Attribute("name")

Jim