fsprojects / FSharp.Data

F# Data: Library for Data Access
https://fsprojects.github.io/FSharp.Data
Other
815 stars 287 forks source link

[XmlProvider] Problem with namespaces #113

Closed ovatsus closed 11 years ago

ovatsus commented 11 years ago
[<Literal>]
let twitterUri = "http://search.twitter.com/search.atom?q=Windows8&rpp=100&lang=en"

type Tweets = XmlProvider<twitterUri>
let feed = Tweets.Load twitterUri

let t = feed.Title

This fails because XmlRuntime.GetChild -> XmlRuntime.GetChildrenArray -> value.XElement.Elements(XName.Get(name)) returns an empty sequence. The problem is that the title element belongs to the http://www.w3.org/2005/Atom namespace and but we are not passing that namespace to XName.Get. We should look at the toplevel namespace of the xml and pass that along when accessing elements.

Also, XmlRuntime.GetChild should give a more descriptive error message stating if it found more than one, or zero elements

This was reported on StackOverflow: http://stackoverflow.com/questions/15753005/f-typeprovider-xmlprovider-gives-system-exception

ovatsus commented 11 years ago

@tpetricek can you create an FSharp.Data tag on stack overflow so we can tag that post (and a few others)? I don't have enough points to create a tag

tpetricek commented 11 years ago

I tagged this one, but I'm not sure what other questions would be good candidates, so if you know any, you should now be able to add the tag ("f#-data"). Thanks!

ovatsus commented 11 years ago

I've tagged a couple more

tpetricek commented 11 years ago

Great! I also added a link to the F# Data README.md.