I hope you already had the chance to download the latest LINQ CTP. This CTP contains important improvements to the Xml features in VB 9.0 which most of them are based on the feedback that we got from many people on our last CTP. This feedback is invaluable to us and to the quality of the final product, so please continue let us know what you think.
Here is a short overview of the new Xml features in VB 9.0:
Xml axis properties: The new syntax for Xml axis properties that I discussed in a prior post enhances code readability and provides the infrastructure for future VB editor improvements. All three axis properties (elements, descendants and attributes) returns collections similar to the semantics of XPath axis.
Value extension property: The "Value" extension property we added to IEmunerable(Of XElement) and IEnumerable(Of XAttribute) returns the value of the first node in these collections. If the IEnumerable is empty, null (nothing) is returned. This property allows easy access to the values of the Xml nodes and reduces the need for a null (nothing) check when programming with XLinq document. In the following example the statement that uses the XLinq API will throw a null reference exception since "year" attribute is missing from the book element, you can cast the XAttribute to avoid the exception of use the Xml axis properties which will return nothing:
Dim book = <book title="Learning Visual Basic"/>
'Null reference exception
Global namespaces for Xml literals: The global Xml namespaces declared in the imports statement can now be used in the Xml literals. This removes the need to declare the namespace in every expression hole, in addition it allow us to optimize the creation of the Xml namespace declaration, and to avoid creating these declarations when they are not needed. Here is an example of applying global Xml namespace to Xml literal:
Imports ns = "http://www.w3.org/1999"
Dim book = _
<ns:Title>Learning Programming Using VB</ns:Title>
We are still investigating adding a global default Xml namespace that will apply to the Xml literals, however this feature is still in the planning and we hope to be able to get it into the Orcas release.
Outlining: for those who did not like the Xml literals taking so much space in the VB code editor, you can now click on the little minus icon on the "selection margin" on the left side of the editor. You can collapse any Xml element that spans across more then one line.
Samples: Check out the cool new samples (ScanReporter and SpecConverter) that highlight the use of Xml literals with LINQ queries. In addition, the CTP contains excellent XLinq samples in C#. Finally, we added to our sample queries sample a set of XQuery use-cases written in VB and updated the 101 XLinq queries with the new syntax.
Blog in Turkish: For those who understand Turkish, check out my teammate Sinan's blog .
Hope you enjoy this CTP, we are looking forward to know what you think and to be able to improve the product based on your feedback