当前位置:编程学习 > XML/UML >>

CSS控制XML与通过js解析xml然后通过html显示xml中的数据

 

使用CSS控制XML的显示

book.css

bookname{ display:block;color:Red}
author{  display:block;font-style:italic}
price{  display:block;colo

book.xml

<?xml version="1.0" encoding="GB2312" ?>
<?xml-stylesheet type="text/css" href="book.css" ?>
<bookstore>
  <book>
    <bookname>java与模式</bookname>
    <author>白艳</author>
    <price>12</price>
  </book>
</bookstore>

 

数据库信息.xml

<?xml version="1.0" encoding="gb2312" ?>
<file>
 <config id="01">
  <url>jdbc:oracle:@thin:lacol:1521:finey</url>
  <user>fineydb</user>
  <password>123456</password>
 </config>

 <config id="02">
  <url>jdbc:oracle:@thin:lacol:1521:fairy</url>
  <user>fairydb</user>
  <password>1314520</password>
 </config>

 <config id="03">
  <url>jdbc:mysql:@thin:lacol:1521:lily</url>
  <user>lilydb</user>
  <password>123456</password>
 </config>

 <config id="04">
  <url>jdbc:sqlserver:@thin:lacol:1521:joho</url>
  <user>Johodb</user>
  <password>123456</password>
 </config>

</file>

 

 

通过js解析xml然后通过html显示xml中的数据

源XML文档scoot.xml

<?xml version="1.0" encoding="gb2312"?>
<scott>
    <data id="0">
        <employnum>7369</employnum>
        <name>SMITH</name>
        <job>CLERK</job>
        <mgr>7902</mgr>
        <hiredate>1980-12-17 00:00:00.0</hiredate>
        <sal>800</sal>
        <comm />
        <depno>20</depno>
    </data>
    <data id="1">
        <employnum>7499</employnum>
        <name>ALLEN</name>
        <job>SALESMAN</job>
        <mgr>7698</mgr>
        <hiredate>1981-02-20 00:00:00.0</hiredate>
        <sal>1600</sal>
        <comm>300</comm>
        <depno>30</depno>
    </data>
    <data id="2">
        <employnum>7521</employnum>
        <name>WARD</name>
        <job>SALESMAN</job>
        <mgr>7698</mgr>
        <hiredate>1981-02-22 00:00:00.0</hiredate>
        <sal>1250</sal>
        <comm>500</comm>
        <depno>30</depno>
    </data>
    <data id="3">
        <employnum>7566</employnum>
        <name>JONES</name>
        <job>MANAGER</job>
        <mgr>7839</mgr>
        <hiredate>1981-04-02 00:00:00.0</hiredate>
        <sal>2975</sal>
        <comm />
        <depno>20</depno>
    </data>
    <data id="4">
        <employnum>7654</employnum>
        <name>MARTIN</name>
        <job>SALESMAN</job>
        <mgr>7698</mgr>
        <hiredate>1981-09-28 00:00:00.0</hiredate>
        <sal>1250</sal>
        <comm>1400</comm>
        <depno>30</depno>
    </data>
    <data id="5">
        <employnum>7698</employnum>
        <name>BLAKE</name>
        <job>MANAGER</job>
        <mgr>7839</mgr>
        <hiredate>1981-05-01 00:00:00.0</hiredate>
        <sal>2850</sal>
        <comm />
        <depno>30</depno>
    </data>
    <data id="6">
        <employnum>7782</employnum>
        <name>CLARK</name>
        <job>MANAGER</job>
        <mgr>7839</mgr>
        <hiredate>1981-06-09 00:00:00.0</hiredate>
        <sal>2450</sal>
        <comm />
        <depno>10</depno>
    </data>
    <data id="7">
        <employnum>7788</employnum>
        <name>SCOTT</name>
        <job>ANALYST</job>
        <mgr>7566</mgr>
        <hiredate>1987-04-19 00:00:00.0</hiredate>
        <sal>3000</sal>
 &nbs

补充:软件开发 , Java ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,