2

Looked at these for a couple solutions--but nothing works
The type 'XmlProvider' is not defined
F# Data New type provider library
F# Data: XML Type Provider

open FSharp.Data
type XMLcountries = XmlProvider<"http://api.worldbank.org/country">
let sampleCountries = XMLcountries.GetSample()
let sampleCountries' = XMLcountries.Load("http://api.worldbank.org/country")

When using the interactive window, I get F# error FS0039: The type 'XmlProvider' is not defined. Is there a better package/library to use XML provider(and JSON too).

I have updated FSharp.Data to version 2.3.1

I added open FSharp.Data.TypeProviders to see if that would work. Still same error.

This is extremely frustrating.

Community
  • 1
  • 1
Aaron M
  • 326
  • 2
  • 13
  • 1
    "*When using the interactive window*" is the key – FSI needs to reference the assembly. – ildjarn Jun 28 '16 at 07:44
  • 1
    possible duplicate of [F#, namespaces, modules, fs and fsx](https://stackoverflow.com/questions/2354984/f-namespaces-modules-fs-and-fsx) – ildjarn Jun 28 '16 at 07:48
  • do you have FSLab (http://fslab.org/) installed? then you could say `#load @"..\..\FSLAB\packages\FSLAB\FsLab.fsx"` and your life would be much easier. Otherwise reference the dll with `#r` or just right click on the Reference and send to F# Interactive. – s952163 Jun 28 '16 at 09:12

1 Answers1

3

Are you sure you have looked at F# Data: XML Type Provider? Because at the very beginning it says:

#r "../../../bin/FSharp.Data.dll"
#r "System.Xml.Linq.dll"
open FSharp.Data

So you have a couple of options, if you don't want to install FSlab, the second one is the easiest for you. You obviously have to adjust the path to match your environment.

  1. Download and install FSLab, then reference FSLab with
    #load @"..\..\FSLAB\packages\FSLAB\FsLab.fsx"
  2. Reference FSharp.Data.dll in your script:
    #r @"..\..\FSLAB\packages\FSharp.Data\lib\net40\FSharp.Data.dll"
  3. Add FSharp.Data to your References in Visual Studio and send the reference to FSI with a rigt-click (I do hope you have installed the Visual F# Power Tools).

the Visual F# Power Tools

s952163
  • 6,276
  • 4
  • 23
  • 47
  • red squiggly lines for #r "../../../bin/FSharp.Data.dll" #r "System.Xml.Linq.dll" FSLAB and Powertools installed – Aaron M Jun 28 '16 at 14:26
  • well, you have to specify the actual path to FSharp.Data.dll... or Just add the Dlls to the references in VS then do Send to F# Interactive. then you won't need to #r it. – s952163 Jun 28 '16 at 14:31
  • I have sent it to the interactive every package to the interactive and i have put the #r about the open section – Aaron M Jun 28 '16 at 14:34
  • its usually good to be specific about the error...can u join f# chat? – s952163 Jun 28 '16 at 14:54
  • I get the same F# error FS0039: The type 'XmlProvider' is not defined. – Aaron M Jun 28 '16 at 14:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/115853/discussion-between-s952163-and-aaron-m). – s952163 Jun 28 '16 at 14:57