F# Xml Type Provider test if node exists

Viewed 310

This seems like it should be trivial. I'm parsing many XML files, some of which contain all of the expected nodes, some of which do not. I need to be able to test for the existence of a node. I am using the F# Xml Type Provider. This code does not work but it illustrates what I am trying to do.

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

type Author = XmlProvider<"""<author name="Paul Feyerabend" born="1924"><height>10</height></author>""">
let sample = Author.Parse("""<author name="Karl Popper" born="1902" />""")
let containsHeight = sample.Height <> null // I want this to return false
1 Answers
Related