문제

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