Skip to content

Instantly share code, notes, and snippets.

@bohdanszymanik
Created June 24, 2020 18:48
Show Gist options
  • Select an option

  • Save bohdanszymanik/38d98c113cc0a0cbb67c32265c50c832 to your computer and use it in GitHub Desktop.

Select an option

Save bohdanszymanik/38d98c113cc0a0cbb67c32265c50c832 to your computer and use it in GitHub Desktop.
(*
<?xml version="1.0" encoding="UTF-8"?>
<Questionnaire type="referee">
<Section id="referee" label="Your details">
<Section id="identity" label="Identity">
<Input id="name" label="Referee name">
<Input id="firstName" label="First name">Douglas</Input>
<Input id="middleName" label="Middle name">Neil</Input>
<Input id="surname" label="Surname">Adams</Input>
</Input>
<Input id="dateOfBirth" label="Date of birth">2008-09-29</Input>
<Input id="gender" label="Gender">MALE</Input>
<Input id="countryOfBirth" label="Country of birth">UK</Input>
</Section>
<Section id="contact" label="Contact">
<Input id="phoneNumbers" label="Phone numbers">
<Input id="workPhoneNumber" label="Work phone number">0123456</Input>
<Input id="homePhoneNumber" label="Home phone number">0126543</Input>
</Input>
</Section>
</Section>
</Questionnaire>
*)
open System.Xml
type Id = Id of string
type Label = Label of string
type Input =
| Id * Label * Value of string
| Input list
type Section =
| Section list
| Id * Label * Input list
type Questionnaire = Section list
let extractQuestionnaire (doc: XmlDocument) =
[for node in doc.ChildNodes do
if node.Name = "Section" then
yield (Section [ for child in node.ChildNodes -> extractSection(child) ] )]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment