xml复习之代码篇

XML 复习之 代码篇

HTML常用标签

常用标记

 <html></html> HTML文件必须的标记
 <head></head> 指定HTML网页的文件信息
 <title></title> 网页标题
 <body></body> 网页主体 文本信息
 <h(n)></h(n)>网页的子标题 从1到6
 <br> 换行显示
 <hr> 水平线

文字标示

<small></small>小字号
<big></big>大字号
<font size=n>字体大小
<basefont size=n>默认字体的大小
<b></b>粗体显示
<i></i>斜体显示
<u></u>下划线
<strike></strike>删除线
<sub></sub>下标
<sup></sup>上标

列表

<dir></dir>以列表方式显示
<menu></menu>以列表方式显示
<ul></ul>
    <ul type= f>
         f = disk 实心圆
         f = circle 空心圆
         f = square 实心方框 

<ol></ol>
    <ol type =f>
        f =A 以大写字母排序
        f =a 以小写字母排序
        f=I 以大写罗马字母排序
        f=i 以小写罗马字母排序
        f=1 以阿拉伯数字排序
    <ol start=n>
        n为编号的起始号

表格

<table></table> 表明表格的范围
    属性
        border 表格框线宽度
        width 表格的宽度 可以是数字也可以是百分比
        height 表格的高度 可以是数字也可以是百分比
        cellspacing 单元格线的宽度
        cellpeddeing 单元格和数据之间的距离
<caption></caption> 表格标题
    align:
        top 标题在表格上
        bottom 标题在表格下
<tr></tr> 表格一行的内容 必须在<tr></tr>中 文字突出显示
<th></th> 表格栏目行中的一项 必须在<tr></tr>中 文字正常显示
    align:
        left 居左
        right 居右
        center 居中
    nowrap:
        数据较多时不换行显示
    width:
        指定宽度
    valign:
        top 文字显示在本行的偏上方位置
        middle 文字显示在本行的中间位置
        bottom 文字显示在本行的偏下方位置
    cospan:
        实现单元格的横向合并 n为合并的单元格的数量
    rowspan:
        实现单元格的纵向合并 n为合并的单元格的数量
<td></td>

色彩

<body></body>
    text= 文本的颜色
    link= 超链接的颜色
    vlink= 鼠标指向的超链接文字
<font color=> 设置某一类文字的颜色

<table bgcolor= > 表格的背景颜色
<td bgcolor= > 某一行的背景颜色
<th bgcolor= > 栏目行的背景颜色
<hr color= > 水平线的颜色

链接

<a href=> 显示内容 </a> 页面链接

<a #标记名>内容</a> 本地链接标记
<a name=标签名> 显示内容</a> 本地链接目标处
<a href="mailto:****@***.***">***</a> 邮箱链接

XML

特殊字符的使用

    <?xml version="1.0" encoding="utf-8" ?>
    <book bookcatagory="&lt;文艺&gt;">
        <bookinfo>
            <title>计算机导论</title>
            <author>丁跃潮等</author>
            <publish>
                <publisher>高等教育出版社</publisher>
            </publish>
            <price>18.00</price>
        </bookinfo>
    </book>

复合元素的用法

       <?xml version="1.0" encoding="utf-8" ?>
        <!DOCTYPE bookinfo[
        <!ELEMENT bookinfo (title,author,publish,price)>
        <!ELEMENT title (#PCDATA)>
        <!ELEMENT author (#PCDATA)>
        <!ELEMENT publish (publisher,ISBN,pubdate)>
        <!ELEMENT publisher (#PCDATA)>
        <!ELEMENT ISBN (#PCDATA)>
        <!ELEMENT pubdate (#PCDATA)>
        <!ELEMENT price (#PCDATA)>
        ]>
        <bookinfo>
            <title>计算机导论</title>
            <author>丁跃潮等</author>
            <publish>
                <publisher>高等教育出版社</publisher>
                <ISBN>7-04-014768-8</ISBN>
                <pubdate>2004.6</pubdate>
            </publish>
            <price>19.7</price>
        </bookinfo>

元素组

    <?xml version="1.0" encoding="utf-8" ?>
        <!DOCTYPE bookinfo[
        <!ELEMENT maininfo (title,author,price)>
        <!ELEMENT bookinfo (booknumb,maininfo+)>
        <!ELEMENT booknumb (#PCDATA)>
        <!ELEMENT title (#PCDATA)>
        <!ELEMENT author (#PCDATA)>
        <!ELEMENT price (#PCDATA)>
        ]>
        <bookinfo>
            <booknumb>2</booknumb>
            <maininfo>
                <title>计算机导论</title>
                <author>丁跃潮等</author>
                <price>19.7</price>
            </maininfo>
        </bookinfo>

外部二进制形式文件的使用

     <?xml version="1.0" encoding="utf-8" ?>
        <!DOCTYPE customers[
        <!ELEMENT customers (customers*)>
        <!ELEMENT customer (username,password,picture)>
        <!ELEMENT username (#PCDATA)>
        <!ELEMENT password (#PCDATA)>
        <!ELEMENT picture EMPTY>
        <!ATTLIST picture pic ENTITIES #REQUIRED>
        <!ATTLIST customer ID ID #REQUIRED>
        <!NOTATION jpg SYSTEM "mspaint.exe">
            <!ENTITY pic1 SYSTEM "a.jpg" NDATA jpg>
            <!ENTITY pic2 SYSTEM "b.jpg" NDATA jpg>
            <!ENTITY pic3 SYSTEM "c.jpg" NDATA jpg>
            <!ENTITY pic4 SYSTEM "d.jpg" NDATA jpg>
        ]>
       <customers>
            <customer ID="c0500103">
                <username>cheaperget</username>
                <password>123456789</password>
                <picture pic ="pic1 pic2" />
            </customer>
            <customer ID="c05002208">
                <username>dreamingboy</username>
                <password>223456789</password>
                <picture pic ="pic3 pic4" />
            </customer>
        </customers>

Schema

XML文档
<?xml version="1.0" encoding="utf-8" ?>
    <book isbn="0-764-58007-8">
        <title>三国演绎</title>
        <author>罗贯中</author>
        <price>80</price>
        <resume>........................省略了。。。。。。。。。。。。</resume>
        <recommendation>经典好书</recommendation>
        <publish>
            <publisher>文艺出版社</publisher>
            <pubdate>1998.10</pubdate>
        </publish>
    </book>
信息模式定义
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="book">
    <xsd:complexType>
    <xsd:sequence>
        <xsd:element name="title" type="xs:string" />
        <xsd:element name="author" type="xs:string" />
        <xsd:element name="price" type="xs:integer" />
        <xsd:element name="resume" type="xs:string" />
        <xsd:element name="recommendation" type="xs:string" />
        <xsd:element name="publish" minOccurs="0" maxOccurs="unbounded" >
            <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="publisher" type="xs:string" />
                <xsd:element name="pubdate" type="xs:date" />
            </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
    </xsd:sequence>
    <xsd:attribute name="isbn" type="xs:string">
    <xsd:complexType>
</xsd:element>
</xsd:schema>
用户自定义简单类型
<xsd:simpleType name="myint">
    <xsd:restiction base="xsd:integer">
        <xsd:minInlusive value="100">
        <xsd:maxInclusive value="999">
    </xsd:restiction>
</xsd:simpleType>
用户自定义枚举类型
<xsd:simpleType name="category">
    <xsd:restiction base="xsd:token">
        <xsd:enumeration value="小说">
        <xsd:enumeration value="散文">
        <xsd:enumeration value="传记">
        <xsd:enumeration value="诗歌">
        <xsd:enumeration value="武侠">
        <xsd:enumeration value="纪实">
    </xsd:restiction>
</xsd:simpleType>
联合类型
<!-- Schema Fragment -->
<xsd:simpleType name="gradeUnion">
<xsd:union>
    <xsd:simpleType name="scoreType">
        <xsd:restriction base="integer">
            <xsd:minInlusive="0" />
            <xsd:maxInclusive="100" />
        </xsd:instriction>
    </xsd:simpleType>

    <xsd:simpleType name="gradeType">
        <xsd:restriction base="token">
            <xsd:enumeration value="优秀" />
            <xsd:enumeration value="良好" />
            <xsd:enumeration value="及格" />
            <xsd:enumeration value="不及格" />
        </xsd:restiction>
    <xsd:simpleType>
</xsd:union>
</simpleType>
复杂类型
<xsd:element name="book">
    <xsd:complexType>
    <xsd:all>(xsd:sequence/xsd:choice[minOccurs maxOccurs = "unbounded"]表示允许任意数量的子元素以任意顺序出现)
        <xsd:element name="title" type="xsd:string" />
    </xsd:all>
    </xsd:complexType>
</xsd:element>

外联数据岛

<HTML>
    <head>
        <title> 外联数据岛</title>
    </head>
    <body>
        <xml id="XMLdata" src = "data.xml"> </xml>
        <h2 align="center">
            <font size="3">数据显示</font>
        </h2>
        <table datasrc ="#XMLdata" border="1" align="center">
            <thead>
                <th>customerID</th>
                <th>order_data</th>
                <th>order_status</th>
                <th>items</th>
            </thead>
            <tr>
                <td><span datafld="coutomerID"></span></td>
                <td><span datafld="oder_data"></span></td>
                <td><span datafld="order_status"></span></td>
                <td><table datarc="#XMLdata" datafld="items">
                        <tr><td><table border="1" datasrc="#XMLdata" datafld = "item">
                            <thead>
                                <th>bookID</th>
                                <th>quantity</th>
                                <th>item_status</th>
                            </thead>
                            <tr>
                                <td><span datafld="bookID"></span></td>                          <td><span datafld="quantity"></span></td>
                                <td><span datafld="item_status"></span></td>
                            </tr>
                        </table></td></tr>
                </table></td>
            </tr>
        </table>
    </body>
</html>

分页显示XML数据源的数据

<OBJECT classid="clsid:550dda30-0541-11d2-9ca9-0060b0ec3d39" id = "XMLDSO" height="0" width="0"></OBJEXT>
<HTML>
    <head>
        <title>分页显示书本信息</title>
    </head>
    <script language="JavaScript">
        var XMLdoc = XMLDSO.XMLDocument;
        XMLDSO.async = false;
        XMLdoc.load("data.xml");
    </script>

    <body>
        <center><b><font size="3">分页显示书本信息</font></b></center>
        <table id =tblbooks datasrc="#XMLDSO" >
            <thread>
                <th>书名</th><th>类别</th><th>书号</th>
                <th>作者</th><th>出版社</th><th>定价</th><th>剩余量</th>
            </thread>
            <tr>
                <td><span datafld="title"></span></td>
                <td><span datafld="bookcategory"></span></td>
                <td><span datafld="ISBN"></span></td>
                <td><span datafld="author"></span></td>
                <td><span datafld="publisher"></span></td>
                <td><span datafld="price"></span></td>
                <td><span datafld="remain"></span></td>
            </tr>
        </table>
        <hr>
        <cenrter>
            <input type="button" onclick="tblbooks.preiousPage()" value="上一页">
            <input type="button" onclick="tblbooks.nextPage()" value="下一页">
            每一页<input type=text value="3" size="5" onblur="tblbooks.dataPageSize = this.value;">笔
        </center>
    </body>
</html>

XSL

网站购物车 文档

data.xml
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="text/xsl" href="tran.xsl" ?>
<shoppingcart>
    <customer>
        <name>赵子龙</name>
        <email>[email protected]</email>
        <zipcode>361021</zipcode>
        <address>中国厦门</address>
    </customer>
    <shoppingitem>
        <item>
            <itemNo>1101</itemNo>
            <itemName>三国演义</itemName>
            <price>80.00</price>
            <publisher>文艺出版社</publisher>
        </item>
    </shoppingitem>
</shoppingcart>
tran.xsl

<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
        <html>
            <head>
                <title>书籍订单</title>
                <style>      </style>
            </head>
            <xsl:apply-templates />
        </html>
    </xsl:template>

    <xsl:template match="shoppingcart">
        <body> <xsl:apply-templates /></body>
    </xsl:template>

    <xsl:template match="shoppingcart/customer">
        <div><xsl:value-of select="name" /></div>
        <div><xsl:value-of select="email" /></div>
        <div><xsl:value-of select="address" /></div>
        <div><xsl:value-of select="zipcode" /></div>
    </xsl:template>

    <xsl:template match="shoppingcart/shoppingitem">
        <table>
            <thread>
                <td><b>编号</b></td>
                <td><b>书名</b></td>
                <td><b>价格</b></td>
                <td><b>出版社</b></td>
            </thread>
            <xsl:for-each select="./item" order-by="itemNo">
                <tr>
                    <td><b><xsl:value-of select="itemNo"></b></td>
                    <td><b><xsl:value-of select="itemName"></b></td>
                    <td><b><xsl:value-of select="price"></b></td>
                    <td><b><xsl:value-of select="publisher"></b></td>
                </tr>
            </xsl:for-each>
        </table>
    </xsl:template>
</xsl:stylesheet>

原文地址:https://www.cnblogs.com/cuizhen/p/9233282.html

时间: 2024-08-01 11:05:22

xml复习之代码篇的相关文章

android流媒体之硬编码【代码篇】

转载此处:http://www.apkbus.com/blog-86476-43829.html 上一篇文章进行了思路和16进制文件的分析.这篇该代码实现了.目前没有在真实手机上测试, android4.0之后的模拟器可以用模拟摄像头或者叫做webcam的[其实就是笔记本摄像头].之后会在程序安装包data/data/edu.ustb.videoencoder/下面会有h264.3gp,sps[存放sps数据].pps[存放pps数据].media.xml[存放找到mdat的位置],/sdcar

C++ XML解析之TinyXML篇(转载)

最近使用TinyXML进行C++ XML解析,感觉使用起来比较简单,很容易上手,本文给出一个使用TinyXML进行XML解析的简单例子,很多复杂的应用都可以基于本例子的方法来完成.以后的文章里会讲解使用Xerces进行C++ XML解析的例子,希望大家一起交流. TinyXML是一个开源的解析XML的解析库,能够用于C++,能够在Windows或Linux中编译.这个解析库的模型通过解析XML文件,然后在内存中生成DOM模型,从而让我们很方便的遍历这棵XML树. DOM模型即文档对象模型,是将整

并行计算复习————第四篇 并行计算软件支撑:并行编程

并行计算复习 第四篇 并行计算软件支撑:并行编程 Ch13 并行程序设计基础 13.1并行语言构造方法 库例程:MPI.Pthreads 扩展串行语言:Fortran90 加编译注释构造:OpenMP 13.2并行性问题 可利用SPMD来伪造MPMD 需要运行MPMD:parbegin S1 S2 S3 parend 可以改造成SPMD: for i = 1 to 3 par-do if i == 1 then S1 else if i == 2 then S2 else if i == 3 t

通过http请求传递xml流和接收xml流的代码示例

通过http请求传递xml流和接收xml流的代码示例 //1.在servlet中post一个xml流:import java.io.OutputStreamWriter;import org.jdom.Document;import org.jdom.Document; public void doPost(HttpServletRequest request, HttpServletResponse response)    throws ServletException, IOExcepti

平衡二叉树,AVL树之代码篇

看完了第一篇博客,相信大家对于平衡二叉树的插入调整以及删除调整已经有了一定的了解,下面,我们开始介绍代码部分. 首先,再次提一下使用的结构定义 1 typedef char KeyType; //关键字 2 typedef struct MyRcdType //记录 3 { 4 KeyType key; 5 }RcdType,*RcdArr; 6 typedef enum MyBFStatus //为了方便平衡因子的赋值,这里进行枚举 7 { //RH,EH,LH分别表示右子树较高,左右子树等高

xml的操作-解析篇

2014-05-04 11:16 吴文付 工作上,学习上,肯定会碰到xml的操作.这里提供详细的xml解析方法. 这里的规划如下:简单的布局3个按钮.3个按钮,对应3种解析xml的方法.分别为 sax解析 dom解析 pull解析 12:56 完成了dom的解析.比较简单. xml的操作-解析篇,布布扣,bubuko.com

java解析XML获取城市代码

运行前先导入dom4j架包,由于我们公司用的代理服务器所以下面我设置了代理ip,不需要的可直接忽略 package com.chengshidaima.tools; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; import java.net.URLConn

SAX解析XML文件实例代码

import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.s

phonegap(cordova) 自己定义插件代码篇(六)----android ,iOS 微信支付工具整合

还是那句话,在使用插件代码篇的时候,请先了解插件机制(如整合原生插件先阅读原生插件文档.非常重要.非常重要!非常重要!),如未了解,请先阅读入门篇.这里就专贴关键代码 必须先把官方sdk 依照要求一步一步的整到自己项目中.然后再来看此代码,这里是cordova 整合代码 如有不明确的.加群 38840127 (function (cordova) { var define = cordova.define; define("cordova/plugin/wxpay", function