I am trying to get a number out of an xml field
...
<Quantity>12</Quantity>
...
via
Some((recipe "Main" "Quantity").text.toInt)
Sometimes there may not be a value in the xml, though. The text will be ""
and this throws an java.lang.NumberFormatException.
What is a clean way to get either an Int or a None?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…