質問

I think I must be missing something essential in my (limited) understanding of type providers.

The XmlProvider does not like this content, and tells me Index was outside the bounds of the array. I think it's something to do with the attributes: in any case if I remove the Xs or the Ys, it works ok.

<root>
    <Points>
        <Point X="0.0" Y="2.0"/>
        <Point X="159.3546" Y="3.0"/>
    </Points>
</root>

Any ideas?

役に立ちましたか?

解決

Which version of F# Data are you using? And how are you referencing the type provider?

I just tried the following using the latest version of F# Data (built from source) and this works fine - however, the latest version fixes a number of bugs so it is quite possible that this was not working earlier. Can you try this using the version FSharp.Data 2.0.0-alpha6 (available on NuGet):

#r "System.Xml.Linq.dll"
#r @"C:\Tomas\Public\FSharp.Data\bin\FSharp.Data.dll"
open FSharp.Data

type X = XmlProvider<"""<root>
    <Points>
        <Point X="0.0" Y="2.0"/>
        <Point X="159.3546" Y="3.0"/>
    </Points>
</root>""">

let x = X.GetSample()
x.Points.GetPoints().[1].X
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top