0

Is there a better ( safer ) way to create a record from a XmlAttributeCollection. The workaround with the array of 3 values seems not the best solution.

type Pattern = { patternName : string; patternExpr : string; group : string }

let attArray = [| for att in xmlNode.Attributes do yield att.Value |]
{patternName = attArray.[0]; patternExpr = attArray.[1]; group = attArray.[2]}
user1120753
  • 639
  • 6
  • 14

1 Answers1

0

The Idea behind XML was that you don't check for valid XML yourself in your code, but instead rely on a Schema for that. Let the built in XML tools validate the structure of the XML document you get, then you can trust it's ok and write your codewithout having to worry about that kind if errors.

That way you can refer to the attributes by name and be sure they're there, wich makes your code more readable.

GJ

Community
  • 1
  • 1
gjvdkamp
  • 9,929
  • 3
  • 38
  • 46