XML Basic-from w3schools.com

xiaoxiao2021-03-06  42

IN Our XML Tutorial You Will Learn What XML IS AND THE DIFCERENCETWEEN XML AND HTML. You will Also Learn How To Start Using XML in your application.

Introduction TO XML

Xml Was Designed to Describe Data and To Focus on What Data IS. HTML WAS Designed to Display Data and To Focus on How Data Looks.

What You Should Already Know Before You Continue, You Should Have Some Basic Understanding of the Following:

WWW, HTML and the basics of building Web pages Web scripting languages ​​like JavaScript or VBScript If you want to study these subjects first, before you start reading about XML, you can find the tutorials you need at W3Schools' Home Page.

What is xml?

XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to describe data XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML With a dtd or XML Schema Is Designed to Be Self-Descriptive

The main difference between XML and HTML XML was designed to carry data XML is not a replacement for HTML.XML and HTML were designed with different goals:. XML was designed to describe data and to focus on what data is.HTML was designed to display Data and to focus on how data loocks. HTML IS About Displaying Information, While XML IS About Describing Information.

XML does not DO anything XML was not designed to DO anything. Maybe it is a little hard to understand, but XML does not DO anything. XML was created to structure, store and to send information. The following example is a note to Tove from Jani, Stored As XML:

TOVE

jani

Reminder

Don't forget me this weekend! The note Has a header and a message body. it Also Has Sender and recent doies not do anything. it is IS Just Pure Information Wrapped in XML Tags. Someone Must Write a Piece of Software To Send, Receive or Display IT.

XML is free and extensible XML tags are not predefined. You must "invent" your own tags. The tags used to mark up HTML documents and the structure of HTML documents are predefined. The author of HTML documents can only use tags that are defined in THE HTML Standard (Like

,

, ETC.). XML Allows The Author To Define His Own Tags and His Own Document Structure. The Tags in The Example Above (Like and ) Are Not Defined in any xml standard. these tags are "invented" by the author of the xml document.

XML is a complement to HTML XML is not a replacement for HTML. It is important to understand that XML is not a replacement for HTML. In future Web development it is most likely that XML will be used to describe the data, while HTML will be Used to format and display The Same Data. My Best Description of XML IS THIS: XML IS A Cross-Platform, Software and Hardware Independent Tool For Transmitting Information.

XML in future Web development XML is going to be everywhere. We have been participating in XML development since its creation. It has been amazing to see how quickly the XML standard has been developed and how quickly a large number of software vendors have adopted the standard . We strongly believe that XML will be as important to the future of the Web as HTML has been to the foundation of the Web and that XML will be the most common tool for all data manipulation and data transmission.XML Joke Question: When should I Use xml? answer: when you need a buzzword in your resume.

How can XML BE USED?

IT Is Important To Understand That XML Was Designed To Store, Carry, And Exchange Data. Xml Was Not Designed to Display Data.

XML can Separate Data from HTML With XML, your data is stored outside your HTML. When HTML is used to display data, the data is stored inside your HTML. With XML, data can be stored in separate XML files. This way you can concentrate on using HTML for data layout and display, and be sure that changes in the underlying data will not require any changes to your HTML. XML data can also be stored inside HTML pages as "Data Islands". You can still concentrate on using HTML only For Formatting and Displaying the Data.

XML is used to Exchange Data With XML, data can be exchanged between incompatible systems. In the real world, computer systems and databases contain data in incompatible formats. One of the most time-consuming challenges for developers has been to exchange data between such systems Over the Internet. Converting The Data TO XML CAN GREATLY Reduce This Complexity and Create Data That Can Be Read by Many Different Types of Applications.

XML and B2B With XML, financial information can be exchanged over the Internet. Expect to see a lot about XML and B2B (Business To Business) in the near future. XML is going to be the main language for exchanging financial information between businesses over the Internet. A lot of interesting B2B applications are under development.XML can be used to Share Data With XML, plain text files can be used to share data. Since XML data is stored in plain text format, XML provides a software- and hardware- independent way of sharing data. This makes it much easier to create data that different applications can work with. It also makes it easier to expand or upgrade a system to new operating systems, servers, applications, and new browsers.

XML can be used to Store Data With XML, plain text files can be used to store data. XML can also be used to store data in files or in databases. Applications can be written to store and retrieve information from the store, and generic applications Can be used to display the data.

XML can make your Data more Useful With XML, your data is available to more users. Since XML is independent of hardware, software and application, you can make your data available to other than only standard HTML browsers. Other clients and applications can access your XML files as data sources, like they are accessing databases. your data can be made available to all kinds of "reading machines" (agents), and it is easier to make your data available for blind people, or people with other disabilities.

XML can be used to Create new Languages ​​XML is the mother of WAP and WML. The Wireless Markup Language (WML), used to markup Internet applications for handheld devices like mobile phones, is written in XML. You can read more about WML in our WML tutorial.If Developers have Sense If they DO have sense, all future applications will exchange their data in XML. The future might give us word processors, spreadsheet applications and databases that can read each other's data in a pure text format, without any conversion Utilities in Between. We can Only Pray That Microsoft And All The Other Software Vendors Will Agree.

XML Syntax

The Syntax Rules of Xml Are Very Simple and Very Strict. The Rules Are Very Easy To Learn, And Very Easy To Use. Because of this, Creating Software That Can Read and Manipulate XML IS VERY EASY TO.

An Example XML Document XML Documents Use A Self-Describing and Simple Syntax.

TOVE

jani

Reminder

don't doget me this weekend!

The first line in the document - the XML declaration - defines the XML version and the character encoding used in the document In this case the document conforms to the 1.0 specification of XML and uses the ISO-8859-1 (Latin. -1 / west european) Character set. The next line describes the root element of the document (like it is saying: "this document is a note":

The Next 4 Lines Describe 4 Child Elements of The Root (To, from, Heading, and Body):

TOVE

jani

Reminder don't forget me this weekend! and finally the last line defines the end of the root element:

Can You Detect from this Example That The XML Document Contains a Note to Tove from Jani? Don't you agree That XML IS PRETTY SELF-Descriptive?

All XML Elements Must Have A Closing Tag with XML, IT ILLEGAL TO OMIT The Closing Tag. In Html Some Elements Do Not Have to Have A Closing Tag. The Following Code Is Legal in HTML:

this is a paragraph

this is another paragraph in Xml All Elements Must Have a closing tag, like this:

this is a paragraph

This is another paragraph Note: You might have noticed from the previous example that the XML declaration did not have a closing tag This is not an error The declaration is not a part of the XML document itself... IT IS Not An XML Element, And It Should Not Have A Closing Tag.

XML Tags Are Case Sensitive Unlike HTML, XML Tags Are Case Sensitive. With XML, The Tag IS Different from The Tag . Opening and Closing Tags Must ThereFore Be Written with The Same Case:

this is incorrect

this is correct

All XML Elements Must Be Properly Nested Improper Nesting of Tags Makes No Sense To Xml. In Html Some Elements Can Be Improperly Nested within Each Other Like this:

this text is bold and italic in Xml All Elements Must Be Properly Nested within Each Other Like this:

this text is bold and italic

All XML documents must have a root element All XML documents must contain a single tag pair to define a root element. All other elements must be within this root element. All elements can have sub elements (child elements). Sub elements must be correctly nested WITHIN THEIR PARENT ELEMENT:

.....

Attribute values ​​must always be quoted With XML, it is illegal to omit quotation marks around attribute values. XML elements can have attributes in name / value pairs just like in HTML. In XML the attribute value must always be quoted. Study the two XML documents Below. The First One is Incorrect, The Second is Correct:

TOVE

jani

TOVE

jani

The Error In The First Document IS That The Date Attribute In The Note Element IS NOT Quoted. This is the correct: Date = "12/11/2002". This is INCORRECT: DATE = 12/11/2002.

With XML, white space is preserved With XML, the white space in your document is not truncated This is unlike HTML With HTML, a sentence like this:.. Hello my name is Tove, will be displayed like this: Hello my name is Tove , Because HTML Reduces Multiple, Connecutive White Space Characters to a Single White Space.

With XML, CR / LF is converted to LF With XML, a new line is always stored as LF Do you know what a typewriter is Well, a typewriter is a mechanical device which was used last century to produce printed documents:.?. - ) After you have typed one line of text on a typewriter, you have to manually return the printing carriage to the left margin position and manually feed the paper up one line. In Windows applications, a new line is normally stored as a pair of characters :.. carriage return (CR) and line feed (LF) The character pair bears some resemblance to the typewriter actions of setting a new line In Unix applications, a new line is normally stored as a LF character Macintosh applications use only a CR. Character to store a new line.comments in xml the syntax for Writing Comments in xml is similar to this of html.

There is nothing special about XML There is nothing special about XML. It is just plain text with the addition of some XML tags enclosed in angle brackets. Software that can handle plain text can also handle XML. In a simple text editor, the XML tags will be visible and will not be handled specially. In an XML-aware application however, the XML tags can be handled specially. The tags may or may not be visible, or have a functional meaning, depending on the nature of the application.

XML Elements

XML Elements Are Extensible and They Have Relationships. XML Elements Have SIMPLE NAMING RULES.

XML Elements Are Extensible XML Documents Can Be Extended to Carry More Information. Look at The Following XML Note Example:

TOVE

jani

don't doget me this weekend!

Let's imagine that we created an application that extracted the , , and elements from the XML document to produce this output: MESSAGE To: ToveFrom: Jani Do not forget me this weekend! Imagine That The Author of The XML Document Added Some Extra Information To IT:

2002-08-01

TOVE

jani

Reminder

don't doget me this weekend!

Should the application break or crash? No. The application should still be able to find the , , and elements in the XML document and produce the same output. XML documents are Extensible.

XML Elements have Relationships Elements are related as parents and children To understand XML terminology, you have to know how relationships between XML elements are named, and how element content is described Imagine that this is a description of a book..:

My first XML Introduction TO XML

What is html what is xml XML Syntax

Elements Must Beve A Closing Tag Elements Must Be Properly Nested Imagine That XML Document Describes The Book:

my first xml </ title></p> <p><prod ID = "33-657" Media = "Paper"> </ proD> <chapter> Introduction to XML</p> <p><para> what is html </ para></p> <p><para> what is xml </ para></p> <p></ chapter></p> <p><Chapter> XML Syntax</p> <p><Para> Elements Must Have a Closing Tag </ Para></p> <p><Para> Elements Must Be Properly Nested </ Para></p> <p></ chapter></p> <p></ Book> Book is the root element. Title, prod, and chapter are child elements of book. Book is the parent element of title, prod, and chapter. Title, prod, and chapter are siblings (or sister elements) because they have the same parent.Elements have Content Elements can have different content types. An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can have element content, mixed content, simple content, or empty content. An element can also have attributes. In the example above, book has element content, because it contains other elements. Chapter has mixed content because it contains both text and other elements. Para has simple content (or text content) because it contains only text. Prod has empty content, because it carries no information. In the example above only the prod element has attributes. The attribute named id has the value "33-657". The attribute named media has the value "paper" .</p> <p>Element Naming XML Elements Must Follow these Naming Rules:</p> <p>Names can contain letters, numbers, and other characters Names must not start with a number or punctuation character Names must not start with the letters xml (or XML or Xml ..) Names can not contain spaces Take care when you "invent" element names and follow these simple rules: Any name can be used, no words are reserved, but the idea is to make names descriptive names with an underscore separator are nice Examples: <first_name>, <last_name> Avoid "-" and ".... "in names. For example, if you name something" first-name, "it could be a mess if your software tries to subtract name from first. Or if you name something" first.name, "your software may think that" name "is a property of the object" first "Element names can be as long as you like, but do not exaggerate names should be short and simple, like this:.. <book_title> not like this:. <the_title_of_the_book> XML documents Often Have a Corresponding Database, in Which Fields EXIST CORRESPONDING TO Elements in The XML Document. a Good practice is to use the naming rules of your database for the elements in the XML documents Non-English letters like éòá are perfectly legal in XML element names, but watch out for problems if your software vendor does not support them The "..: "SHOULD NOT BE USED IN Element Names Because It is reserved to be used for something caled namespaces (more lat) .xml attributes</p> <p>XML Elements CAN Have Attributes in The Start Tag, Just Like HTML. Attributes Are Used To Provide Additional Information About Elements.</p> <p>XML Attributes XML elements can have attributes From HTML you will remember this:. <IMG SRC = "computer.gif"> The SRC attribute provides additional information about the IMG element In HTML (and in XML) attributes provide additional information about elements.. : <img src = "computer.gif"></p> <p><a href="demo.asp"> Attributes often provide information that is not a part of the data In the example below, the file type is irrelevant to the data, but important to the software that wants to manipulate the element.:</p> <p><file type = "gif"> computer.gif </ file></p> <p>Quote Styles, "Female" or 'female'? Attribute Values ​​Must Always Be Enclosed in Quotes, But Either Single OR Double Quotes Can Be Used. For a Person's Sex, The Person Tag Can Be Written Like this:</p> <p><Person Sex = "Female"> Or Like this:</p> <p><Person Sex = 'female'> Note: if The Attribute Value Itself Contains Double Quotes Itself Contains Double Single Quotes, LIKE IN this Example:</p> <p><Gangster Name = 'George "SHOTGUN" Ziegler'> NOTE: IF The Attribute Value Itself Contains Single Quotes Its Necessary To Use Double Quotes, LIKE IN this Example:</p> <p><gangster name = "George 'Shotgun' Ziegler"></p> <p>Use of elements vs. Attributes Data Can Be Stored in Child Elements Or in Attributes:</p> <p><Person Sex = "FeMale"></p> <p><firstname> Anna </ firstname></p> <p><lastname> Smith </ lastname></p> <p></ persons></p> <p><Person></p> <p><SEX> FEMALE </ SEX></p> <p><firstname> Anna </ firstname></p> <p><lastname> Smith </ lastname></p> <p></ Person> In the first example sex is an attribute. In the last, sex is a child element. Both examples provide the same information. There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them Use child elements if the information feels like data.My Favorite Way I like to store data in child elements The following three XML documents contain exactly the same information..: A Date Attribute IS Used In The First EXAMPLE:</p> <p><Note Date = "12/11/2002"></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note> a date element is buy in the second example:</p> <p><Note></p> <p><Date> 12/11/2002 </ date></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note> An Expanded Date Element IS Used in The Third: (this is my favorite):</p> <p><Note></p> <p><Date></p> <p><day> 12 </ day></p> <p><month> 11 </ month></p> <p><year> 2002 </ year></p> <p></ date></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note></p> <p>Avoid Using Attributes? SHOULD you Avoid Using Attributes? Some of the problem:</p> <p>attributes can not contain multiple values ​​(child elements can) attributes are not easily expandable (for future changes) attributes can not describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values ​​are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document If you use attributes as containers for data, you end up with documents that are difficult to read and maintain Try to use elements to describe data use attributes only to.. Provide Information That Is Not Relected To The Data. Don't End Up Like this (if you think this locks like xml, you have not understood the point): <note day = "12" MONTH = "11" Year = "2002 "</p> <p>To = "TOVE" from = "jani" Heading = "Reminder"</p> <p>Body = "Don't forget me this weekend!"></p> <p></ Note></p> <p>An Exception to my Attribute rule Rules always have exceptions My rule about attributes has one exception:. Sometimes I assign ID references to elements These ID references can be used to access XML elements in much the same way as the NAME or ID attributes in HTML. This Example Demonstrates this:</p> <p><Messages></p> <p><Note ID = "P501"></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note></p> <p><Note ID = "P502"></p> <p><to> jani </ to></p> <p><from> tove </ from></p> <p><Heading> Re: Reminder </ Heading></p> <p><body> i will! </ body></p> <p></ Note></p> <p></ Messages> The Id in these Examples Identifier, To Identify The Different Notes in The xml file, and not a part of the note data. What i am trying to say me is that metadata (Data) About data) Should Be Stored As Attributes, And That Data Itself Should Be Stored As Elements.xml Validation</p> <p>XML with Correct Syntax Is Well FORMED XML. XML Validated Against A DTD IS Valid XML.</p> <p>. "Well Formed" XML documents A "Well Formed" XML document has correct XML syntax A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters:</p> <p><? Xml Version = "1.0" encoding = "ISO-8859-1"?></p> <p><Note></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note></p> <p>"Valid" XML Documents A "Valid" XML Document Also Conforms To A DTD. A "Valid" XML Document IS A "Well formed" XML Document, Which Also Conforms To The Rules of A Document Type Definition (DTD):</p> <p><? Xml Version = "1.0" encoding = "ISO-8859-1"?></p> <p><! DOCTYPE Note System "InternalNote.dtd"></p> <p><Note></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note></p> <p>XML DTD A DTD defines the legal elements of an XML document. The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. You can read more about DTD, and how to validate your XML documents in our DTD tutorial.XML Schema XML Schema is an XML based alternative to DTD. W3C supports an alternative to DTD called XML Schema. You can read more about XML Schema in our Schema tutorial.</p> <p>Errors will Stop you Errors in XML documents will stop the XML program. The W3C XML specification states that a program should not continue to process an XML document if it finds a validation error. The reason is that XML software should be easy to write, and that all XML documents should be compatible. with HTML it was possible to create documents with lots of errors (like when you forget an end tag). One of the main reasons that HTML browsers are so big and incompatible, is that they have their own Ways to Figure ut what a document shouth look loo means. with xml this shouth lot not be posible.</p> <p>A general XML Validator To Help You Validate Your Xml Files, We Have Created This Link So That You Can Validate Any XML File.</p> <p>XML Browser Support</p> <p>In Our XML Tutorial We Have Focused On Internet Explorer 5.0 .</p> <p>XML on this Web Site Many browsers support XML. We are focusing on Internet Explorer 5.0 . Some of you have complained about this, but we think this is the most practical way to demonstrate real XML examples for you over the Internet.</p> <p>XML in Mozilla Firefox 1.0 Mozilla Firefox 1.0 Supports the XML 1.0 Standard.</p> <p>XML in Netscape 6 Netscape 6 supports XML To look at the XML source in Netscape 6:.. Right-click on the page and select "View Page Source" .XML in Internet Explorer 5.0 Internet Explorer 5.0 supports the XML 1.0 standard Internet Explorer 5.0 supports most of the international standards for XML 1.0 and the XML DOM (Document Object Model) These standards are set by the World Wide Web Consortium (W3C) Internet Explorer 5.0 has the following XML support..:</p> <p>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:</p> <p>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.</p> <p>Viewing XML Files</p> <p>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.</p> <p>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 Source" OR "View Source" from the Browser Menu. in Netscape 6: Open THE XML File (Via a Link OR), The 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</p> <p>Other XML Examples Viewing some XML documents will help you get the XML feeling. An XML CD catalogThis is my father's CD collection, stored as XML data (old and boring titles I think .... :-)). An XML plant catalogThis is A Plant Catalog from a Plat Shop, Stored As XML Data. A Simple Food Menuthis Is A Breakfast Food Menu from A Restaurant, Stored As XML Data.</p> <p>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</p> <p>WITH CSS (Cascading Style Sheets) You can add display information to an xml document.</p> <p>DISPLAYING YOURE XML FITY CSS? Would You Use Css To Format Your Future XML Files? No, We Don't think Giving It A Try: Take a Look At this XML File: The cd catalog dam Look at this style, view: the cd catalog formatted with the css file Below is a fraction of the xml file. The second type = "text / css" href = "cd_catalog .css "?>, links the xml file to the css file:</p> <p><? Xml Version = "1.0" encoding = "ISO-8859-1"?></p> <p><? Xml-stylesheet type = "text / css" href = "cd_catalog.css"?></p> <p><Catalog></p> <p><CD></p> <p><Title> Empire Burlesque </ Title></p> <p><Artist> Bob Dylan </ Artist></p> <p><Country> USA </ country></p> <p><Company> Columbia </ company></p> <p><Price> 10.90 </ price></p> <p><Year> 1985 </ year></p> <p></ Cd></p> <p><CD></p> <p><Title> hide your heart </ title></p> <p><Artist> Bonnie Tyler </ artist></p> <p><Country> UK </ country></p> <p><Company> CBS Records </ company></p> <p><Price> 9.90 </ price> <year> 1988 </ year></p> <p></ Cd></p> <p>.</p> <p>.</p> <p>.</p> <p>.</p> <p></ 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).</p> <p>Creating your future Homepages with XML Will you be writing your future Homepages in XML No, we do not 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 buy to create fulure homepages.</p> <p>Displaying XML with XSL</p> <p>WITH XSL You CAN Add Display Information TO Your XML Document.</p> <p>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:</p> <p><? Xml Version = "1.0" encoding = "ISO-8859-1"?></p> <p><? xml-stylesheet type = "text / xsl" href = "simple.xsl"?></p> <p><Breakfast_Menu></p> <p><food></p> <p><name> Belgian Waffles </ name></p> <p><Price> $ 5.95 </ price></p> <p><description></p> <p>Two of Our Famous Belgian Waffles</p> <p></ description></p> <p><Calories> 650 </ CALORIES></p> <p></ food></p> <p></ Breakfast_Menu> if You Want to Learn More About XSL, Please Visit Our XSL Tutorial.xml in Data Islands</p> <p>WITH Internet Explorer 5.0 and higher, XML Can Be Embedded Withnin HTML Pages in Data Islands.</p> <p>XML Embedded in Html The Unofficial <XML> Tag IS Used To Embed XML Data With HTML. XML Data Can Be Embedded Directly in An Html Page Like this:</p> <p><XML ID = "Note"></p> <p><Note></p> <p><to> TOVE </ TO></p> <p><from> jani </ from></p> <p><Heading> Reminder </ Heading></p> <p><body> don't doget me this weekend! </ body></p> <p></ Note></p> <p></ xml> OR a Separate XML File Can Be Embedded Like this:</p> <p><XML ID = "Note" src = "Note.xml"></p> <p></ xml> Note That The <XML> Tag is an HTML Element, Not an XML ELEMENT.</p> <p>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.</p> <p><html></p> <p><body></p> <p><xml id = "cdcat" src = "cd_catalog.xml"> </ xml></p> <p><Table Border = "1" Datasrc = "# CDCAT"></p> <p><tr></p> <p><TD> <span datafld = "artist"> </ span> </ td></p> <p><TD> <span datafld = "title"> </ span> </ td></p> <p></ TR></p> <p></ TABLE></p> <p></ body></p> <p></ 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 <TAD>, <TBody>, And <Tfoot > .THE Microsoft XML Parser</p> <p>To read and update - create and manipulate - an XML Document, You NEED AN XML Parser.</p> <p>. 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.:</p> <p>JavaScript, Vbscript, Perl, VB, Java, C and more w3c XML 1.0 and XML DOM DTD AND VALIDATION IF you are using Javascript in Ie 5.0, You Create An XML Document Object with the Following Code:</p> <p>VAR Xmldoc = New ActiveXObject ("Microsoft.xmldom") if you are useful vbscript, you create the xml document Object with the following code:</p> <p>Set Xmldoc = CreateObject ("Microsoft.xmLDom") if you are useful vbscript in asp, you can use the folowing code:</p> <p>Set Xmldoc = Server.createObject ("Microsoft.xmldom")</p> <p>INTO THE XML PARSER:</p> <p><script type = "text / javascript"></p> <p>VAR Xmldoc = New ActiveXObject ("Microsoft.xmldom")</p> <p>XMLDoc.async = "false"</p> <p>XMLDoc.Load ("Note.xml")</p> <p>// ....... processing the docuument goes here</p> <p></ Script> The second line in the code above creates an instance of the Microsoft XML parser. The third line turns off asynchronized loading, to make sure that the parser will not continue execution before the document is fully loaded. The fourth line tells the Parser to load the xml document called note.xml.Loading Pure XML Text Into the Parser XML Text Can Also Be loaded from a text string. The following code loads a text string into the xml parser:</p> <p><script type = "text / javascript"></p> <p>Var text = "<Note>"</p> <p>TEXT = TEXT <to> Tove </ to> <from> jani </ from> "</p> <p>Text = text "<Heading> Reminder </ Heading>"</p> <p>TEXT = TEXT <Body> Don't forget me this weekend! </ body> "</p> <p>Text = text "</ Note>"</p> <p>VAR Xmldoc = New ActiveXObject ("Microsoft.xmldom")</p> <p>XMLDoc.async = "false"</p> <p>XMLDoc.LoadXml (Text)</p> <p>// ....... processing the docuument goes here</p> <p></ script> Note That The "LoadXml" Method (Instead of the "load" method) is buy to load a text string.</p> <p>Displaying XML with JavaScript To display XML you can use JavaScript JavaScript (or VBScript) can be used to import data from an XML file and display the XML data inside an HTML page To see how XML and HTML complement each other this way;.. First look at the XML document (note.xml), then open the HTML document (note.htm) that contains a JavaScript which reads the XML file and displays the information inside predefined spans in the HTML page. To see how it works, Try It Yourself you can see a lot more of this kind of javascript in our dan</p> <p>XML in Real Life</p> <p>Some real-life examples of how XML can be used to carry information.Example: XML News XMLNews is a specification for exchanging news and other information Using such a standard makes it easier for both news producers and news consumers to produce, receive, and. Archive Any Kind of News Information Across Different Hardware, Software, And Programming Languages.</p> <p>An Example XML News Document:</p> <p><? Xml Version = "1.0" encoding = "ISO-8859-1"?></p> <p><nitf></p> <p><HEAD></p> <p><Title> Colombia Earthquake </ Title></p> <p></ hEAD></p> <p><body></p> <p><body.head></p> <p><headline></p> <p><hl1> 143 dead in colombia Earthquake </ hl1></p> <p></ headline></p> <p><BYLINE></p> <p><bytag> by jared kotler, Associated press Writer </ bytag></p> <p></ BYLINE></p> <p><dateline></p> <p><location> Bogota, Colombia </ location></p> <p><story.date> Monday January 25 1999 7:28 et </story.date></p> <p></ dateline></p> <p></BODY.HEAD></p> <p></ body></p> <p></ nitf></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-67119.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="67119" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.048</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'vD8a8CdHEioDC6sjizeqh1bqsW6Org3mGoYEVGOwj1sgoiI1mR_2BrxKqphVlIrUQTWCv4k8evvHKjiIfy'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>