w3pop.com :: ÍøÂçѧԺ :: XML :: ä¯ÀÀ XML Îļþ
Raw XML files can be viewed in Mozilla, Firefox, Opera, Internet Explorer, and Netscape 6+.
ÔʼµÄXMLµÄÎļþ¿ÉÒÔÔÚMozilla Firefox¡¢Opera¡¢Internet Explorer ºÍ Netscape 6+ ÖÐä¯ÀÀ¡£
However, to make XML documents display as nice web pages, you will have to add some display information.
È»¶ø£¬ÎªÁËÈÃXMLÎĵµÏÔʾ³öƯÁÁµÄÍøÒ³£¬Äã±ØÐëÌí¼ÓһЩÏÔʾÐÅÏ¢¡£
In Firefox and Internet Explorer:
ÔÚ Firefox ºÍ Internet Explorer ÖÐä¯ÀÀ£º
Open the XML file (typically by clicking on a link) - 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.
´ò¿ªXMLÎļþ£¨Ò»°ã¾ÍÊǵã»÷Ò»ÏÂÁ´½Ó£©——XMLÎĵµÖÐÏÔʾµÄ¸ùĿ¼ºÍ×ÓĿ¼ÊÇÓɲÊÉ«±ê¼ÇµÄ£¬µã»÷Ŀ¼×ó±ßµÄ¼Ó£¨+£©¼õ£¨-£©ºÅ£¬¿ÉÒÔÕ¹¿ªÊÕ»ØÄ¿Â¼½á¹¹¡£Ñ¡Ôñä¯ÀÀÆ÷²Ëµ¥ÉÏµÄ“Ò³ÃæÔ´´úÂ딣¨"View Page Source"£©»ò“Ô´Îļþ”£¨ "View Source"£©
In Netscape 6:
ÔÚNetscape 6ä¯ÀÀ£º
Open the XML file, 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.
´ò¿ªXMLÎļþ£¬ÓÒ»÷XMLÎļþ£¬Ñ¡Ôñ“Ô´Îļþ”¡£³öÏֵĽ«ÊÇÓÐÏÔʾ²ÊÉ«±ê¼ÇµÄ¸ù×ÓĿ¼µÄXMLÎĵµ¡£
In Opera 7 and 8:
ÔÚOpera 7 and 8ä¯ÀÀ:
In Opera 7: Open the XML file, then right-click in XML file and select "Frame" / "View Source". The XML document will be displayed as plain text. In Opera 8: Open the XML file, then right-click in XML file and select "Source". The XML document will be displayed as plain text.
ÔÚOpera 7ÉÏ: ´ò¿ªXMLÎļþ£¬ÓÒ»÷XMLÎļþ£¬Ñ¡Ôñ“¿ò¼Ü”/“ä¯ÀÀ×ÊÔ´”£¨"Frame" / "View Source"£©¡£XMLÎĵµ½«ÒÔÆÕͨÎı¾ÏÔʾ¡£ÔÚOpera 8: ´ò¿ªXMLÎļþ£¬ÓÒ»÷XMLÎļþ£¬Ñ¡Ôñ“×ÊÔ´”£¨"Source”£©¡£XMLÎĵµ½«ÒÔÆÕͨÎı¾ÏÔʾ
Look at this XML file: note.xml
¿´Õâ·ÝXMLÎļþ£º: note.xml
Note: Do not expect XML files to be formatted like HTML documents!
Note: ¿É±ðÖ¸ÍûXMLÎļþ»áÏñHTMLÎļþÒ»Ñù²¼¾Ö¡£
If an erroneous XML file is opened, the browser will report the error.
Èç¹û´ò¿ªÒ»·ÝÓдíµÄXMLÎļþ£¬ä¯ÀÀÆ÷»á±¨¸æ´íÎóÐÅÏ¢¡£
Look at this XML file: note_error.xml
¿´Õâ·Ý: note_error.xml
Viewing some XML documents will help you get the XML feeling.
ä¯ÀÀһЩXMLÎĵµ¿ÉÒÔ°ïÄãÕÒµ½Ò»µã“XML¸Ð¾õ”¡£
An XML CD catalog
This is my father's CD collection, stored as XML data (old and boring titles I guess... :-)).
Ò»·ÝCDÃû¼µÄXMLÎļþ
ÕâÊÇÒÔXMLµÄÊý¾ÝÐÎʽ´æ´¢µÄ¸¸Ç×µÄCD¼¯£¨ÎÒÏëÕâЩ¸èÃûÓÖÀÏÓÖ·¦Î¶£º£©£©
An XML plant catalog
This is a plant catalog from a plant shop, stored as XML data.
Ò»·ÝÖ²ÎïÃû¼µÄXMLÎļþ
ÕâÊÇÒÔXMLµÄÊý¾ÝÐÎʽ´æ´¢µÄÀ´×Ô»¨»ÜÉ̵êÖеÄÖ²ÎïÃû¼¡£
A Simple Food Menu
This is a breakfast food menu from a restaurant, stored as XML data.
¼òµ¥µÄʳÎï²Ëµ¥
ÕâÊÇÒÔXMLµÄÊý¾ÝÐÎʽ´æ´¢µÄÀ´×Բ͹ݵÄÔçµã²Ëµ¥¡£
XML documents do not carry information about how to display the data.
XMLÎĵµ²¢Ã»Óаüº¬¹ØÓÚÊý¾ÝÏÔʾÑùʽµÄÐÅÏ¢¡£
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.
ÒòΪXML±êÇ©ÊÇ×÷Õß×Ô¶¨ÒåµÄ£¬ä¯ÀÀÆ÷²¢²»ÖªµÀÕâ¸ö±êÇ©¸ÃÈçºÎÏÔʾ£¬È磺ä¯ÀÀÆ÷²»ÖªµÀÕâÀïµÄ<table> ÃèÊöµÄÊÇ“HTML ±í¸ñ”£¨HTML table£©£¬»¹ÊÇ“²Í×À”£¨dining table£©¡£
Without any information about how to display the data, most browsers will just display the XML document as it is.
ÒòΪXMLÖв¢Ã»Óаüº¬XML Êý¾ÝµÄÏÔʾÐÅÏ¢£¬ËùÒÔ´ó¶àÊýä¯ÀÀÆ÷Ö»»áÏÔʾ×î³õµÄXMLÎĵµ¡£
In the next chapters, we will take a look at different solutions to the display problem, using CSS, XSL, JavaScript, and XML Data Islands.
ÔÚÏÂÃæ¼¸ÕÂÀÎÒÃÇ»áѧϰ½â¾öÏÔʾÎÊÌâµÄһЩ²»Í¬·½·¨£¬ÈçʹÓÃCSS¡¢ XSL¡¢ JavaScript ºÍ XML Êý¾Ýµº¡£