品易云推流 关闭
文章详情页
文章 > Python基础教程 > python XML数据是什么

python XML数据是什么

Python XML

头像

小妮浅浅

2021-06-09 09:44:082978浏览 · 0收藏 · 0评论

1、概念

XML 格式的数据既便于机器读取,也便于人工读取。

xml 格式说明:

Tag: 使用<和>包围的部分;

Element:被Tag包围的部分,如 2003,可以认为是一个节点,它可以有子节点;

Attribute:在Tag中可能存在的 name/value 对,如示例中的 title="Enemy Behind",一般表示属性。

2、实例

<?xml version="1.0" encoding="UTF-8"?>
<collection shelf="New Arrivals">
    <movie title="Enemy Behind">
        <type>War, Thriller</type>
        <format>DVD</format>
        <year>2003</year>
        <rating>PG</rating>
        <stars>10</stars>
        <description>Talk about a US-Japan war</description>
    </movie>
    <movie title="Transformers">
        <type>Anime, Science Fiction</type>
        <format>DVD</format>
        <year>1989</year>
        <rating>R</rating>
        <stars>8</stars>
        <description>A schientific fiction</description>
    </movie>
    <movie title="Trigun">
        <type>Anime, Action</type>
        <format>DVD</format>
        <episodes>4</episodes>
        <rating>PG</rating>
        <stars>10</stars>
        <description>Vash the Stampede!</description>
    </movie>
    <movie title="Ishtar">
        <type>Comedy</type>
        <format>VHS</format>
        <rating>PG</rating>
        <stars>2</stars>
        <description>Viewable boredom</description>
    </movie>
</collection>

以上就是python XML数据的介绍,希望对大家有所帮助。更多Python学习指路:python基础教程

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图