转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
XML Basic-from w3schools.com         ★★★★

XML Basic-from w3schools.com

作者:闵涛 文章来源:闵涛的学习笔记 点击数:4070 更新时间:2009/4/23 15:41:28
ds are set by the World Wide Web Consortium (W3C).

Internet Explorer 5.0 has the following XML support:

  • Viewing of XML documents
  • Full support for W3C DTD standards
  • XML embedded in HTML as Data Islands
  • Binding XML data to HTML elements
  • Transforming and displaying XML with XSL
  • Displaying XML with CSS
  • Access to the XML DOM

Internet Explorer 5.0 also has support for Behaviors:

  • Behaviors is a Microsoft-only technology  
  • Behaviors can separate scripts from an HTML page.
  • Behaviors can store XML data on the client''''s disk.

Examples of all these features are given in the next chapters of this web site.



Viewing XML Files

prev next

Raw XML files can be viewed in Mozilla Firefox, IE 5.0+ and in Netscape 6.

However, to make XML documents to display like nice web pages, you will have to add some display information.


Viewing XML Files

In Mozilla Firefox and IE 5.0+:

Click on a link to an XML file, type the direct URL in the address bar, or double-click on the name of an XML file in a folder. The XML document will be displayed with color-coded root and child elements. A plus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the element structure. To view the raw XML source (without the + and - signs), select "View Page Source" or "View Source" from the browser menu.

In Netscape 6:

Open the XML file (via a link or URL), then right-click in XML file and select "View Page Source". The XML document will then be displayed with color-coded root and child elements.

Look at this XML file: note.xml

Note: Do not expect XML files to be formatted like HTML documents!


Viewing an Invalid XML File

If an erroneous XML file is opened, the browser will report the error.

Look at this XML file: note_error.xml


Other XML Examples

Viewing some XML documents will help you get the XML feeling.

An XML CD catalog
This is my father''''s CD collection, stored as XML data (old and boring titles I think.... :-)).

An XML plant catalog
This is a plant catalog from a plant shop, stored as XML data.

A Simple Food Menu
This is a breakfast food menu from a restaurant, stored as XML data.


Why does XML display like this?

XML documents do not carry information about how to display the data.

Since XML tags are "invented" by the author of the XML document, browsers do not know if a tag like <table> describes an HTML table or a dining table.

Without any information about how to display the data, most browsers will just display the XML document as it is.

In the next chapters, we will take a look at different solutions to the display problem, using CSS, XSL, JavaScript, and XML Data Islands.



Displaying XML with CSS

back next

With CSS (Cascading Style Sheets) you can add display information to an XML document.


Displaying your future XML files with CSS?

Would you use CSS to format your future XML files? No, we don''''t think so! But we could not resist giving it a try:

Take a look at this XML file: The CD catalog

Then look at this style sheet: The CSS file

Finally, view: The CD catalog formatted with the CSS file

Below is a fraction of the XML file. The second line, <?xml-stylesheet type="text/css" href="cd_catalog.css"?>, links the XML file to the CSS file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="cd_catalog.css"?>
<CATALOG>
  <CD>
    <TITLE>Empire Burlesque</TITLE>
    <ARTIST>Bob Dylan</ARTIST>
    <COUNTRY>USA</COUNTRY>
    <COMPANY>Columbia</COMPANY>
    <PRICE>10.90</PRICE>
    <YEAR>1985</YEAR>
  </CD>
  <CD>
    <TITLE>Hide your heart</TITLE>
    <ARTIST>Bonnie Tyler</ARTIST>
    <COUNTRY>UK</COUNTRY>
    <COMPANY>CBS Records</COMPANY>
    <PRICE>9.90</PRICE>
    <YEAR>1988</YEAR>
  </CD>
.
.
.
.
</CATALOG>   

We DO NOT believe that formatting XML with CSS is the future of the Web. Even if it looks right to use CSS this way, we DO believe that formatting with XSL will be the new standard (as soon as all main browsers support it).


Creating your future Homepages with XML?

Will you be writing your future Homepages in XML? No, we don''''t think you will! But we could not resist giving it a try : A homepage written in XML.

We DO NOT believe that XML will be used to create future Homepages.



Displaying XML with XSL

back next

With XSL you can add display information to your XML document.


Displaying XML with XSL

XSL is the preferred style sheet language of XML.

XSL (the eXtensible Stylesheet Language) is far more sophisticated than CSS. One way to use XSL is to transform XML into HTML before it is displayed by the browser as demonstrated in these examples:

If you have Netscape 6 or IE 5 or higher you can view the XML file and the XSL style sheet.

View the result in IE 6

View the result in IE 5

Below is a fraction of the XML file, with an added XSL reference. The second line, <?xml-stylesheet type="text/xsl" href="simple.xsl"?>, links the XML file to the XSL file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<breakfast_menu>
  <food>
    <name>Belgian Waffles</name>
    <price>$5.95</price>
    <description>
       two of our famous Belgian Waffles
    </description>
    <calories>650</calories>
  </food>
</breakfast_menu>

If you want to learn more about XSL, please visit our XSL tutorial.



XML in Data Islands

prev next

With Internet Explorer 5.0 and higher, XML can be embedded within HTML pages in Data Islands.


XML Embedded in HTML

The unofficial <xml> tag is used to embed XML data within HTML.

XML data can be embedded directly in an HTML page like this:

<xml id="note">
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don''''t forget me this weekend!</body>
</note>
</xml>

Or a separate XML file can be embedded like this:

<xml id="note" src="note.xml">
</xml>

Note that the <xml> tag is an HTML element, not an XML element.


Data Binding

Data Islands can be bound to HTML elements (like HTML tables). 

In the example below, an XML Data Island with an ID "cdcat" is loaded from an external XML file. An HTML table is bound to the Data Island with a data source attribute, and finally the tabledata elements are bound to the XML data with a data field attribute inside a span.

<html>
<body>

<xml id="cdcat" src="cd_catalog.xml"></xml>

<table border="1" datasrc="#cdcat">
<tr>
<td><span datafld="ARTIST"></span></td>
<td><span datafld="TITLE"></span></td>
</tr>
</table>

</body>
</html>

If you are running IE 5.0 or higher, you can try it yourself.

With IE 5.0 and higher you can also view the external XML file.

Also try this example, demonstrating <thead>, <tbody>, and <tfoot>.



The Microsoft XML Parser

prev next

To read and update - create and manipulate - an XML document, you need an XML parser.


Using the XML parser

The Microsoft XML parser comes with Microsoft Internet Explorer 5.0.

Once you have installed IE 5.0, the parser is available to scripts, both inside HTML documents and inside ASP files. The parser features a language-neutral programming model that supports:

教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台