DEVBUZZ Homepage Dynamic HTML display from your eVB application using XML/XSL
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | Starting Out

Dynamic HTML display from your eVB application using XML/XSL
Written by Jason Hawgood  [author's bio]  [read 56100 times]
Edited by Derek

Download the code   Discuss this article   eVB Ver 3.0   

Page 1  Page 2  Page 3 

Overview

In this article I will demonstrate a technique for retrieving Extensible Markup Language (XML) data from a SQL Server over the web, and then applying Extensible Stylesheet Language (XSL) to the returned data and outputting HTML directly to your eVB application.

Requirements

  • Optional: XML Support Installed on SQL Server 2000, check out the XML support in Microsoft® SQL Server™ 2000. (NOTE: if you do not have access to SQL Server with XML support installed, I have included pre-generated files for the sample application.)
  • WebBrowserCE, a web browser control for eVB, download a trial version.
  • MSXML version 2.0 (msxml.dll).

The Application

With the next generation of pocket applications XML will be the primary transport mechanism for data from information sources like a databases or web services. That said, how can developers robustly output XML data to Pocket PC users. One approach I will explore in this article is using HTML from an eVB application using the WebBrowserCE control from IntelProg.com.

Setting Up the Application

When using XML from eVB you will need to set references to the MSXML.dll and the WebBrowserCE 1.0 Type library. For detailed instruction on registering the WebBrowserCE library for your device, see the ReadMe.txt file included with the control. Additionally, copy the Employees.xml, Employees.xsl, EmployeesDetail.xsl and NWINDTRADERS.gif files to the “\windows\start menu\” directory in emulation or your device.


Reference Microsoft XML, version 2.0 and WebBrowserCE 1.0 Type Library

Requesting XML Data

Now, for the fun stuff. Here is a snippet of the Employees.xml file that we will transform with XSL.

If you do not have SQL Server with SQLXML support you can use the static XML file include with the source code. Be sure to make the necessary changes to the BuildDirectory subroutine described in the code comments. SQL Server XML support is a very powerful technology that allows extremely fast retrieval of XML directly from a SQL Server via HTTP protocol. For more information, see Microsoft® SQL Server™ 2000.

To begin we need to define several global level variables to handle the XML and XSL document objects and the WebBrowserCE control.

'Global XML object
Public gXMLDoc As MSXML.DOMDocument

'Global XSL object
Public gXSLDoc As MSXML.DOMDocument

'WebBrowser Control
Public objHtml As WEBBROWSERCELib.HTMLViewerCtl

'HTML to render
Public gsHTML As String
'XMLSQL Service URL
Public gURL As String

In the Form_Load event handler of the main form, add the following code.

Set objHtml = CreateObjectWithEvents("WebBrowserCE.HTMLViewerCtl", "HTMLView_")

'Full version requires license'
objHtml.LicenseKey = ""
objHtml.create (frmContainer.hWnd)

'Define Initial Position of HTML control
objHtml.Left = 0
objHtml.Top = 49
objHtml.Width = 240
objHtml.Height = 195

'Define Service URL, NOTE: you can use a template xml file instead of submitting query directly
gURL= _ "http://YOURSERVER/NWINDS?SQL=Select+*+from+Employees+order+
by+LastName+for+xml+raw&root=EmployeesList"

Call BuildDirectory

The proceeding code will instantiate the WebBrowserCE control, and assign the start up location and size. Now we can call the BuildDirectory subroutine to display the text. This subroutine wraps the call the SQL server and displays the HTML output.

We can then load the XML directly into our global XMLDOM object with the loadXML method, which in turn calls the GetXMLByHTTP function.

Set gXMLDoc = CreateObject("Microsoft.XMLDOM")gXMLDoc.loadXML GetXMLByHTTP(gURL)

The GetXMLByHTTP function makes a HTTP request to SQL Server for our XML data using the XMLHTTP object. Notice we are returning our XML data as a string variable that has been stripped of encoding and reference entities replaced.

Next Page 

Back to Starting Out | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP