


WML Elementary Tutorial: Understanding WML from Practical Applications
学习自然语言的最好方法就是溶入相应的语言环境在交流中学习,学习一种编程语言的最好方法就是看例程。为了帮助大家建立wml应用的第一印象,所以请大家先看第一个例子:
<?xml version="1.0"?> <!doctype wml public "-//wapforum//dtd wml 1.1//en" "http://www.wapforum.org/dtd/wml_1.1.xml"> <wml> <template> <do type="PRev" label="back"> <prev/> <!--provide a button you can clink to back a step--> </do> </template> <card id="friends" title="hot link"> <p> <a href="http://wap.sian.com.cn/">sina wap</a><br/> <a href="#nextcard">next card</a> </p> </card> <card id="nextcard"> <p> this is the second card. </p> </card> </wml>
通过以上示例大家应该了解到以下内容:
1、语法:wml的语法与html相似,仍然是一种标记语言,而且延续了xml语法规则
2、元素:在xml和wml 语言中,语言的基本元素称之为"标签"
标签必须被 < 和 > 括起来。
大多数标签都包括"起""止"两部分,例如:<p>…</p>
某些特殊标签可以只有一个标签,但是必须有结束标记,例如:<prev/>
3、属性:xml语言的标签可以包含很多属性,给标签提供必要的附加信息
属性内容通常在起始标签内使用
属性只作为参数为标签提供必要的信息,不会被浏览器显示
属性的值需要被引号括起来,可以是单引号或者双引号,引号可以成对嵌套使用
例如:
<card id="friends" title="hot link">
4、注释
注释内容是方便制作者阅读源代码,不会被浏览器显示
wml不支持注释嵌套
例如:
<!-- this is a comment. -->
5、文档结构
wml文档是由card和deck构成的,一个deck是一个或多个card的集合。在得到客户终端的请求之后,wml从网络上把deck发送到客户的浏览器,访问者可以浏览deck内包含的所有card,而不必从网上单独下载每一个card。
其他一些示例中没有涉及到的基本内容:
6、大小写敏感
无论是标签元素还是属性内容都是大小写敏感的,这一点继承了xml的严格特性,任何大小写错误都可能导致访问错误,这是wml制作者必须注意的问题。
7、躲避语法检查的方法-cdata
cdata内的数据内容都会被当作文本来处理,从而避开语法检查,直接作为文本显示。
示例:
< ! [ cdata [ this ia <b> a test ] ] >
显示结果为
this ia <b> a test
8、定义变量
wml可以使用变量供浏览器和script使用,通过在deck中的一个card上设置变量,其他card不必重新设置就可以直接调用。
变量的语法如下:
$identifier $(identifier) $(identifier:conversion)
如果变量内容包含空格就需要用圆括号括起来。由于变量在语法中有最高的优先级,包含变量声明字符的字符串会被当作变量对待,所以如果要显示$,就一定要连续使用两个$。
示例:
<p> your account has $$15.00 in it.</p>
显示结果为:
your account has $15.00 in it
xml是一种语法非常严格的语言,wml也继承了这种规则,任何地不规范语法都会导致错误。
以上就是WML初级教程之从实际应用中了解WML的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

Using Python to merge and deduplicate XML data XML (eXtensibleMarkupLanguage) is a markup language used to store and transmit data. When processing XML data, sometimes we need to merge multiple XML files into one, or remove duplicate data. This article will introduce how to use Python to implement XML data merging and deduplication, and give corresponding code examples. 1. XML data merging When we have multiple XML files, we need to merge them

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

Implementing filtering and sorting of XML data using Python Introduction: XML is a commonly used data exchange format that stores data in the form of tags and attributes. When processing XML data, we often need to filter and sort the data. Python provides many useful tools and libraries to process XML data. This article will introduce how to use Python to filter and sort XML data. Reading the XML file Before we begin, we need to read the XML file. Python has many XML processing libraries,

Importing XML data into the database using PHP Introduction: During development, we often need to import external data into the database for further processing and analysis. As a commonly used data exchange format, XML is often used to store and transmit structured data. This article will introduce how to use PHP to import XML data into a database. Step 1: Parse the XML file First, we need to parse the XML file and extract the required data. PHP provides several ways to parse XML, the most commonly used of which is using Simple

Python implements conversion between XML and JSON Introduction: In the daily development process, we often need to convert data between different formats. XML and JSON are common data exchange formats. In Python, we can use various libraries to convert between XML and JSON. This article will introduce several commonly used methods, with code examples. 1. To convert XML to JSON in Python, we can use the xml.etree.ElementTree module

Handling Errors and Exceptions in XML Using Python XML is a commonly used data format used to store and represent structured data. When we use Python to process XML, sometimes we may encounter some errors and exceptions. In this article, I will introduce how to use Python to handle errors and exceptions in XML, and provide some sample code for reference. Use try-except statement to catch XML parsing errors When we use Python to parse XML, sometimes we may encounter some

Python parses special characters and escape sequences in XML XML (eXtensibleMarkupLanguage) is a commonly used data exchange format used to transfer and store data between different systems. When processing XML files, you often encounter situations that contain special characters and escape sequences, which may cause parsing errors or misinterpretation of the data. Therefore, when parsing XML files using Python, we need to understand how to handle these special characters and escape sequences. 1. Special characters and
