Volta と LINQ to XML は相性最高 → と思ったけど無理っぽい
(追記)コンパイルは通るけど JavaScript 版ではダメっぽい.要調査.
(追記2)結局 JavaScript モードで動かすときにとりあえず色々大変そうということで,ちょっと保留.
VSUG DAY 2007 Winter の小野さんのセッションで LINQ to XML が楽しそうだったので初挑戦.
using System; using Microsoft.LiveLabs.Volta.Html; using Microsoft.LiveLabs.Volta.Xml; using System.Linq; using System.Xml; using System.Xml.Linq; // needs System.XML.dll // needs System.Xml.Linq.dll namespace VoltaApplication1 { public partial class VoltaPage1 : Page { public VoltaPage1() { InitializeComponent(); var button = new Button() { InnerText = "Read!" }; var input = new Input() { Value = @"http://weather.livedoor.com/forecast/rss/forecastmap.xml" }; var para = new Paragraph() { button, new Span(){ InnerText = " from: "}, input, }; button.Click += () => { var url = input.Value; var table = new Table() { new TableBody ( from areaelem in XElement.Load(url).Descendants(@"area") from pref in areaelem.Descendants(@"pref") let cities = pref.Descendants(@"city") .Select( item => item.Attribute("title").Value ) .ToArray() let citiesStr = string.Join( ", ", cities ) select new TableRow() { new TableCell() { InnerText = pref.Attribute("title").Value }, new TableCell() { InnerText = citiesStr } } as HtmlElement ) }; this.Document.Body.Add(table); }; this.Document.Body.Add(para); } } }