1、概念
XML 格式数据不仅便于机器读取,而且便于人工读取。
xml 格式说明:
Tag: 使用<和>包围部分;
Element:被标签包围的部分,如标签 2003,可以认为是一个节点,可以有子节点;
Attribute:可能存在于标签中 name/value 是的,例如 title="Enemy Behind",一般表示属性。
2、实例
<?xmlversion="1.0"encoding="UTF-8"?> <collectionshelf="NewArrivals"> <movietitle="EnemyBehind"> <type>War,Thriller</type> <format>DVD</format> <year>2003</year> <rating>PG</rating> <stars>10</stars> <description>TalkaboutaUS-Japanwar</description> </movie> <movietitle="Transformers"> <type>Anime,ScienceFiction</type> <format>DVD</format> <year>1989</year> <rating>R</rating> <stars>8</stars> <description>Aschientificfiction</description> </movie> <movietitle="Trigun"> <type>Anime,Action</type> <format>DVD</format> <episodes>4</episodes> <rating>PG</rating> <stars>10</stars> <description>VashtheStampede!</description> </movie> <movietitle="Ishtar"> <type>Comedy</type> <format>VHS</format> <rating>PG</rating> <stars>2</stars> <description>Viewableboredom</description> </movie> </collection>
以上是python 希望XML数据的介绍对大家有所帮助。更多Python学习指导:python基础教程
本教程的操作环境:windows7系统,Python 3.9.1,DELL G3电脑。