質問

I'm building an XML parser in Scala and want to be defensive against user mistakes. If the user gives a tag that I don't support (e.g., <named> rather than <name>) or, more generally, puts a tag in the wrong place, I want to detect it and throw an error. How do I do this the Scala way?

役に立ちましたか?

解決

The best suggestion I have received thus far is to build an XML schema and use that to validate the file. w3schools show how to build a schema here. There exists a variety of tools and classes that use these schemas to validate XML. I hope to update this answer soon with the approach I find works most elegantly!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top