I am stuck. I get a response (how does not matter) that is an xml document represented as a string. The problem is that response can be of different XML schemas. I need to determine the schema type and THEN parse it to use it as I see it. I could cheat and just look for an identifier (string match) in the response (string xml).
But is there a way using the FSharp.Data XML stuff to do that match?
type ResponseType1 = FSharp.Data.XmlProvider<"""<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xSuccess xmlns:ns2="http://www.x.com"><Token>sample</Token></xSuccess>""">
type ResponseType2 = FSharp.Data.XmlProvider<"""<?xml version="1.0" encoding="UTF-8" standalone="yes"?><aFault xmlns:ns2="http://www.x.com"><Message>sample</Message></aFault>""">
//send request
//for simplicity the response is a string in XML format
let rawResponseString = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?><xSuccess xmlns:ns2="http://www.x.com"><Token>abcdef</Token></xSuccess>"""
//let x2 = do something to rawResponseString here so I can match the type??
let eval x2 = match x2 with
| :? ResponseType1 -> printfn "this response is a ResponseType1"
| :? ResponseType2 -> printfn "this response is a ResponseType2"
let rt1 x =
let x' = ResponseType1.Parse(x)
x'.Token
let rt2 x =
let x' = ResponseType2.Parse(x)
x'.Message