• 技术文章 >Python技术 >Python基础教程

    python XML数据是什么

    小妮浅浅小妮浅浅2021-06-09 09:44:08原创2883

    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电脑。

    专题推荐:python xml
    品易云
    上一篇:python读取csv的不同形式 下一篇:python ElementTree解析的方法

    相关文章推荐

    • 三分钟理解JOSN与XML的区别• 如何理解XML解析库?• python怎么读取xml• python lxml安装失败怎么解决• python xml解析中文乱码怎么办• python怎么安装lxml• python安装lxml出错如何解决

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网