Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
Available now!
Buy at Amazon US or
Buy at Amazon UK



Articles

» Windows API reference
» Webcam streaming in VB.NET
» Remoting with firewalls
» RSA from first principles
» Key & MouseLogger in .NET
» Networking Resource Kit for .NET
» Migrating VB6 Winsock to VB.NET
» Migrating C++ sockets to C#
» RFC Reference guide
» COM Reference guide
» WMI Reference guide
» SQL stored procedures
» TCP & UDP port reference
» NET Framework reference
» Ethernet Type codes
» MAC address assignments
» DLL entry point reference
» Boost SQL performance
» Free SMS Messaging
» Internet Explorer

Contact us

Convert WML to HTML in VB.NET

Many cellular & mobile phones now support Internet access via WAP (wireless application protocol) or more advanced technologies such as iMode or cHTML.

Unfortunately there is a big gap between what is available on the web in HTML format, and what is available in WAP-readable WML (Wireless Markup Language format).

This article describes how to convert WML into HTML by stripping out any features of HTML that are not available in WML, and converting the HTML form format with that of WML. All this is done with some clever string parsing in VB.NET. You build this into an ASP.NET web application, or a custom server to dynamically convert website content into WAP format once the ACCEPT HTTP header of the client included text/vnd.wap.wml – and thus could be reasonably assumed to be a WAP phone, not a browser. This article only deals with WML to HTML conversion, if you’re looking to implement a dynamic website converter, you should find the section on WAP programming in Network Programming in .NET (Buy at Amazon UK) (Buy at Amazon US) an invaluable resource.

Before we get down and dirty into the code, let’s look at the differences between WML and HTML.

  • WAP phones do not support standard graphics such as Gifs or Jpegs, they do support a black-and-white image format called WBMP (Wireless Bitmap)
  • WAP phones cannot show applets, Flash movies or any other embedded objects. Frames, DHTML, JavaScript etc. are out too.
  • WAP phones are limited to 2000 characters of text.
  • You cannot view WAP sites on your browser, for this, I recommend using the openwave UP SDK

    In order for a Wap phone to ensure correct media, the MIME type for WML must be returned in the HTTP header as displayed below.

Status: 200 OK
Content-type: text/vnd.wap.wml

    If your server does not know the MIME type for wml, you can change it by trying the following

  • If your Server is an 'Apache' , create a file called .htaccess in the directory you wish to place your wml files, with the following content: addtype text/vnd.wap.wml wml If you have cgi access, you can make your WML file the default file in a directory by adding the following lines to your WML homepage. Then execute chmod 755 index.cgi

#!{location of perl executable}
print "Content-type:text/vnd.wap\n\n";
print <<END;
{WML homepage goes here}
END
;

  • For Windows Servers, you can add a MIME type directly into Windows registry by adding the following entries using REGEDIT :

    HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/vnd.wap.wml
    HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/vnd.wap.wml\Extention = ".wml"

The following is a list of Html tags that can be translated to WML. Items denoted by an asterix are handled by WAP phones but are not handled by the example WML to HTML converter. The reason for this omission is because many sites may contain malformed HTML, where tags are incorrectly nested. To give an example, the HTML: <b><I>Bold Italic</b></I> will render in Internet explorer, but because the bold tag is closed before the italic tag, then it will be seen as being malformed, and will not be rendered by WAP browsers.

<br>

line break

<p>

Paragraph *

<b>

bold *

<big>

big text *

<small>

small text *

<strong>

strong text *

<form>

Forms (Get & Post versions)

<input type="text">

textboxes

<input type="submit">

submit buttons

<a>

hyperlinks (http & mailto )

<i>

italic *

<u>

underline *

META HTTP-EQUIV="refresh"

Timed site redirection

<table>,<td>,<tr>

Tables *

Below left is example HTML forms, directly opposite is the WML equivalent.

<form method="Get" action="A">
 <input name="B">
 <input type="submit" label="C">
</form>

<input name="B"/>
<do type="accept" label="C">
 <go href="A?B=$(B)"/>
</do>

<form method="Post" action="A">
 <input name="B">
 <input type="submit" label="C">
</form>

<input name="B">
<do type="accept" label="C">
 <go href="A" method="Post">
  <postfield name="B" value="$(B)"/>
 </go>
</do>

<Meta HTTP-equiv="refresh" content="A ; URL=B">

<onevent type="ontimer">
 <go href="B"/>
</onevent>
<timer value="A"/>

<texarea name="A">
</textarea>

<input name="A"/>

<select name='A'>
 <option value='B'>C
 ...
</select>
</textarea>

<select name="A">
 <option value="B">C</option>
 ...
</select>

Source code 

(Related Article) 



Google

Copyright 2013 Open Merchant Account Ltd.