scala解析xml
XML is a form of semi structured data which is organized in the form of trees. Semi structured data is helpful when you serialize the program data for saving in a file or shipping across a network. It defines a standardized document which is easy to read an interpret. XML stands for eXtensible Markup Language.
XML是半结构化数据的一种形式,它以树的形式进行组织。 当您序列化程序数据以保存在文件中或通过网络传送时,半结构化数据很有用。 它定义了易于阅读解释的标准化文档。 XML代表可扩展标记语言 。
XML consists of two basic elements text and tags. Text is a sequence of characters. Tags consists of a less than sign alphanumeric character and greater than sign. An end tag is same as start tag except that it consists of a slash in the end. Start tag and end tag must have the same label.
XML由文本和标签这两个基本元素组成。 文本是一个字符序列。 标签由小于符号的字母数字字符和大于符号的字符组成。 结束标记与开始标记相同,不同之处在于它在结尾处包含一个斜杠。 起始标签和结束标签必须具有相同的标签。
For example;
例如;
<school>
<standard>4</standard>
</school>
Above is valid XML as the start and end tag match each other.
上面是有效的XML,因为开始和结束标记相互匹配。
<school><standard>6</standard> 7
Above is invalid XML as the end tag is not specified.
上面是无效的XML,因为未指定结束标记。
<school><standard>8 </school></standard>
Above XML is also invalid because the standard tag which is the child should be closed first and then the parent tag school should be closed.
上面的XML也是无效的,因为应该先关闭作为孩子的标准标签,然后再关闭父标签学校。
Since tags have to be matched, XML are structured as nested elements. The start and end tags forms a pair of matching elements and elements can be nested within each other. In the above example standard is the nested element.
由于必须匹配标签,因此XML被构造为嵌套元素。 开始和结束标签形成一对匹配元素,并且元素可以彼此嵌套。 在上面的示例中,标准是嵌套元素。
The shorthand notation which is the start tag followed by the slash indicates the start and end tag. One tag with a slash indicates an empty element.
缩写符号是开始标签,后跟斜杠,表示开始标签和结束标签。 一个带斜杠的标记表示一个空元素。
For instance in below XML standard
is an empty element.
例如,在下面的XML standard
是一个空元素。
<school> <standard /> </school>
Start tags can have attributes. An attr