有効なxmlと思われるものにXmlProviderを添付しました(IEで表示され、W3Cツールによって検証されます)
プログラムを書くと、すべての型がチェックされ、コンパイルできます。ただし、実行時に次のエラーが発生します。
Data at the root level is invalid. Line 1, position 1.
アクセスすると
let posts = (TyPosts.Parse lastposts).GetEntries()
entry はノード名です。
=> ブレークポイントはどこに配置すればよいですか?
実際のデータ アクセスではなく、TP の構造を破ることしかできませんでした。
初期 pb を再現するためのスクリプトを次に示します。modif は最初の 2 つの dll のみです。
#r @"Z:\clones\FSharp.Data\bin\v40\FSharp.Data.dll"
#r @"Z:\clones\FSharp.Data\bin\v40\FSharp.Data.DesignTime.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll"
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll"
open System
open System.Net
open FSharp.Data
open System.IO;
open System.Text;
open System.Xml;
[<Literal>]
let lastposts = "lastposts.xml"
let phase0 () =
let fetch (url : string, auth) =
use client = new WebClient()
client.Headers.Add("user-agent", @"Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US")
client.DownloadString url
let write(filename, content:string) =
use f= new StreamWriter(filename, false)
f.Write(content)
let posts () = fetch(@"http://squarism.com/feed/atom/", false)
write( __SOURCE_DIRECTORY__ + "/"+ lastposts, posts())
phase0()
[<Literal>]
let res = __SOURCE_DIRECTORY__
type TyPosts = XmlProvider<lastposts,ResolutionFolder=res>
let posts = (TyPosts.Parse lastposts).GetEntries() // <-- TCHETCHENIA HERE !!