Out of the Angle Brackets
Recently, I had a problem where there wasn't a code testing harness that would do exactly what I wanted. I want to grab my code snippet directly from my word document, compile it, run it, and validate the output. In more technical terms, I want to parse some WordML to grab text formatted with a given style. Further, I want to put a comment on the first line of the formatted text, and be able to grab the comment. The comment will contain the metadata that tells how to compile and run the code. My word docs are stored in WordML (which is XML). My experiment was to see how easy it would be to pick apart the WordML using XLinq.
In more technical terms, I want to parse some WordML to grab text formatted with a given style. Further, I want to put a comment on the first line of the formatted text, and be able to grab the comment. The comment will contain the metadata that tells how to compile and run the code.
This example introduces Linq to Amazon, which allows querying Amazon for books using Linq! It uses Linq's extensibility to allow for language-integrated queries against a book catalog. The Linq query gets converted to REST URLs supported by Amazon's web services. These services return XML. The results are converted from XML to .NET objects using Linq to XML.
Return rss...<item> This expressions uses the descendants axis support in VB 9 which can be interpreted as: give me all “item” elements underneath the rss element regardless of where they occur in the heirarchy. VB9 also has support for child axis’ which can be used to get all elements of a given name directly under a given element. For example to return all the channel elements underneath the root rss element one could use the following syntax. Return rss.<channel>...While Xml literals and axis properties aren’t something that is likely to make or break a programmers language decision it does make working with Xml in VB 9 a “pure joy” ®
Return rss...<item>
This expressions uses the descendants axis support in VB 9 which can be interpreted as: give me all “item” elements underneath the rss element regardless of where they occur in the heirarchy. VB9 also has support for child axis’ which can be used to get all elements of a given name directly under a given element. For example to return all the channel elements underneath the root rss element one could use the following syntax.
Return rss.<channel>
While Xml literals and axis properties aren’t something that is likely to make or break a programmers language decision it does make working with Xml in VB 9 a “pure joy” ®
PingBack from http://blogrssblog.info/microsoft-xml-teams-weblog-linq-to-xml-in-action/
PingBack from http://fixmycrediteasily.info/story.php?id=18167