XML 提供商无法识别标签
XML Provider does not recognize tags
我正在使用 XML provider 处理 xml 个文件,或者我正在尝试使用它。
看下面的代码:
open System
open System.IO
open System.Xml.Linq
open FSharp.Data
open System.Net
type InputXml = XmlProvider<"C:\Temp\sample.xml">
[<EntryPoint>]
let main argv =
let input = InputXml.Load("C:\Temp\sample.xml")
for customer in input.GetCustomers() do
for order in customer.GetOrders() do
for line in order.GetOrderLines() do
printfn "Customer: %s, Order: %s, Item: %s, Quantity: %d" customer.Name order.Number line.Item line.Quantity
Console.ReadLine() |> ignore
0 // return an integer exit code
我遇到了编译器错误
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
The field, constructor or member 'GetCustomers' is not defined D:\f#\samples\Program.fs 16 27 samples
xml 文件结构如下:
<?xml version="1.0" encoding="utf-8" ?>
<Customers>
<Customer name="ACME">
<Order Number="A012345">
<OrderLine Item="widget" Quantity="1"/>
</Order>
<Order Number="A012346">
<OrderLine Item="trinket" Quantity="2"/>
</Order>
</Customer>
<Customer name="Southwind">
<Order Number="A012347">
<OrderLine Item="skyhook" Quantity="3"/>
<OrderLine Item="gizmo" Quantity="4"/>
</Order>
</Customer>
</Customers>
我做错了什么?
您使用哪个版本的软件包?
如果我从 NuGet 引用当前 2.1.1
,XmlProvider
就像一个魅力并将节点呈现为属性。
open System
open FSharp.Data
type InputXml = XmlProvider<"C:\Temp\sample.xml">
[<EntryPoint>]
let main argv =
let input = InputXml.Load("C:\Temp\sample.xml")
for customer in input.Customers do
for order in customer.Orders do
for line in order.OrderLines do
printfn "Customer: %s, Order: %s, Item: %s, Quantity: %d" customer.Name order.Number line.Item line.Quantity
Console.ReadLine() |> ignore
0 // return an integer exit code
我正在使用 XML provider 处理 xml 个文件,或者我正在尝试使用它。 看下面的代码:
open System
open System.IO
open System.Xml.Linq
open FSharp.Data
open System.Net
type InputXml = XmlProvider<"C:\Temp\sample.xml">
[<EntryPoint>]
let main argv =
let input = InputXml.Load("C:\Temp\sample.xml")
for customer in input.GetCustomers() do
for order in customer.GetOrders() do
for line in order.GetOrderLines() do
printfn "Customer: %s, Order: %s, Item: %s, Quantity: %d" customer.Name order.Number line.Item line.Quantity
Console.ReadLine() |> ignore
0 // return an integer exit code
我遇到了编译器错误
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
The field, constructor or member 'GetCustomers' is not defined D:\f#\samples\Program.fs 16 27 samples
xml 文件结构如下:
<?xml version="1.0" encoding="utf-8" ?>
<Customers>
<Customer name="ACME">
<Order Number="A012345">
<OrderLine Item="widget" Quantity="1"/>
</Order>
<Order Number="A012346">
<OrderLine Item="trinket" Quantity="2"/>
</Order>
</Customer>
<Customer name="Southwind">
<Order Number="A012347">
<OrderLine Item="skyhook" Quantity="3"/>
<OrderLine Item="gizmo" Quantity="4"/>
</Order>
</Customer>
</Customers>
我做错了什么?
您使用哪个版本的软件包?
如果我从 NuGet 引用当前 2.1.1
,XmlProvider
就像一个魅力并将节点呈现为属性。
open System
open FSharp.Data
type InputXml = XmlProvider<"C:\Temp\sample.xml">
[<EntryPoint>]
let main argv =
let input = InputXml.Load("C:\Temp\sample.xml")
for customer in input.Customers do
for order in customer.Orders do
for line in order.OrderLines do
printfn "Customer: %s, Order: %s, Item: %s, Quantity: %d" customer.Name order.Number line.Item line.Quantity
Console.ReadLine() |> ignore
0 // return an integer exit code