Xml 简明教程
XML - Tree Structure
XML 文档始终是描述性的。树结构通常称为 XML Tree ,它在轻松描述任何 XML 文档方面发挥着重要作用。
An XML document is always descriptive. The tree structure is often referred to as XML Tree and plays an important role to describe any XML document easily.
树结构包含根(父)元素、子元素等等。通过使用树结构,你可以了解从根开始的所有后续分支和子分支。解析从根开始,然后向下移动到一个元素的第一分支,从那里取第一个分支,依次类推到叶子节点。
The tree structure contains root (parent) elements, child elements and so on. By using tree structure, you can get to know all succeeding branches and sub-branches starting from the root. The parsing starts at the root, then moves down the first branch to an element, take the first branch from there, and so on to the leaf nodes.
Example
以下示例演示了简单的 XML 树结构 −
Following example demonstrates simple XML tree structure −
<?xml version = "1.0"?>
<Company>
<Employee>
<FirstName>Tanmay</FirstName>
<LastName>Patil</LastName>
<ContactNo>1234567890</ContactNo>
<Email>tanmaypatil@xyz.com</Email>
<Address>
<City>Bangalore</City>
<State>Karnataka</State>
<Zip>560212</Zip>
</Address>
</Employee>
</Company>
以下树结构表示上述 XML 文档 −
Following tree structure represents the above XML document −
在上述图表中,有一个名为 <company> 的根元素。在其中,还有一个元素 <Employee>。在员工元素内部,有五个分支,分别命名为 <FirstName>、<LastName>、<ContactNo>、<Email> 和 <Address>。在 <Address> 元素内部,有三个子分支,分别命名为 <City> <State> 和 <Zip>。
In the above diagram, there is a root element named as <company>. Inside that, there is one more element <Employee>. Inside the employee element, there are five branches named <FirstName>, <LastName>, <ContactNo>, <Email>, and <Address>. Inside the <Address> element, there are three sub-branches, named <City> <State> and <Zip>.