Proceed to WirelessDevNet Home Page
Publications, e-books, and more! Community Tutorials Store Downloads, tools, & Freebies! IT Career Center News Home
newnav.gif

Newsletters
EMail Address:



   Content
  - Articles
  - Columns
  - Training
  - Library
  - Glossary
 
   Career Center
  - Career Center Home
  - View Jobs
  - Post A Job
  - Resumes/CVs
  - Resource Center
 
   Marketplace
  - Marketplace Home
  - Software Products
  - Wireless Market Data
  - Technical Books
 
   News
  - Daily News
  - Submit News
  - Events Calendar
  - Unsubscribe
  - Delivery Options
 
   Community
  - Discussion Boards
  - Mailing List
  - Mailing List Archives
 
   About Us
  - About WirelessDevNet
  - Wireless Source Disks
  - Partners
  - About MindSites Group
  - Advertising Information
 
INDEX
>XMLCast Introduction
>Parsing the XML
>Output as [simple]HTML
>Output as RSS
>Output as WML

Content Management and Distribution Using XML

Output as [simple]HTML

Getting the XML from the document is pretty straightforward XML stuff. Outputting is when the tricky part comes in because there are four ways we can output the HTML:
  • Full HTML Summary -- A summary page with just the title and a short summary for each article
  • Full HTML Article -- A page with the requested article in its entirety
  • Simple HTML Summary -- Same a full except scaled down HTML (no font tags, to tables, etc.)
  • Simple HTML Article -- Same as full article scaled down
After we've parsed the XML with our ParseXML function, we use the outHTML function to shoot the data back out to the browser (formatted dynamically) via ASP's Response.Write. Here's the complete outHTML function, we'll go through it in a second:

outHTML function

Private Sub outHTML(bSummary, bSimple) ' ***************************************** ' this subroutine outputs the HTML (or simple HTML, If bSimple = True) ' For the summary (bSummary = True) or main article ' ***************************************** Dim sHeading ' HEADING Dim sLink ' LINK Dim sSummary ' SUMMARY ' Write HTML Headers Response.Write "<HTML><HEAD><TITLE>Wireless Developer Network News - " _ & sDate & "</TITLE></HEAD>" & vbCrLf If not bSimple Then %><!-- #INCLUDE file="top.html" --><% Response.Write fontize("<B>Wireless Developer Network News</b>", _ "Verdana, Arial, Helvetica", 3) Else Response.Write "<img src = " & chr(34) & sLogo & chr(34) & ">" & vbCrLf End If Response.Write "<br><br>" & sDate & "<br>" ' Loop through Articles Dim i ' generic counter For i = 1 to UBound(arArticles) ' Set variables sHeading = arArticles(i).Heading sLink = arArticles(i).Link sSummary = arArticles(i).Summary If bSummary Then sHeading = "<a href = ""xmlcast.asp?out=" & outType & "&link=" _ & sLink & chr(34) & ">" & sHeading & "</a>" sBody = sSummary Else sBody = " For p = 1 to UBound(arArticles(i).Paras) sBody = sBody & arArticles(i).Paras(p) & "<br><br>" & vbCrLf Next ' p End If 'fontize (put appropriate <font> tags around) text If not simple If not bSimple Then sHeading = fontize(sHeading, "Verdana, Arial, Helvetica", 2) sBody = fontize(sBody, "Verdana, Arial, Helvetica", 2) sDate = fontize(sDate, "Verdana,Arial, Helvetica", 2) End If If (qsLink = "") or (qsLink = sLink) Then Response.Write "<br><b>" & sHeading & "</b><br><br>" & sBody _ & "<br>" & vbCrLf If qsLink = sLink Then Exit For End If Next ' i ' Write HTML Footers If Not bSimple Then %><!-- #INCLUDE file="bottom.html" --><% Else Response.Write "</BODY></HTML>" End If End Sub The outHTML function takes two parameters: a boolean for if this is a summary page or the full article, and a boolean for if the output is regular HTML or simple HTML (We're all about code efficiency, so we combined the regular HTML and the simple HTML into one function, after all, it's all HTML, right? One's just got a bit more formatting.)

The first thing we do is write out the HTML headers, which is necessary regardless of what we're outputting. Then we check to see if we're doing simple or full HTML, and supply an include template file to lead our full HTML output, or just print out a scaled down logo for simple HTML. Then we loop through the articles array (arArticles) and pull the Heading, Link, and Summary data from it. The next If statement checks to see if we're outputting a summary page (a page with the titles linked to the full articles, and a one sentence summary for each article) or the full article, in which case we loop through the Paras array and pull out each paragraph. It then fills the sHeading and sBody variables with the appropriate content. The next bit of code checks if we're outputting simple or full HTML. If it's full, we "fontize" it, which means we send the text to a function that puts beginning and ending <FONT> tags around the text and returns it. If we're outputting simple HTML, there's no need for font tags, it would just slow down the transfer, and most browsers that will be handling the simple HTML don't have great <FONT> support anyway. We then check to see if we are outputting the full article, in which case we check to see if the article we're on in the loop is the article requested, and if so, stop looping, we're done. Finally, if the output is full HTML, we include our bottom template.

Viola! We've can get four different kinds of output by calling our page as so:

  • Full HTML Summary -- http://.../xmlcast.asp?out=htmlsummary
  • Full HTML Article -- http://.../xmlcast.asp?out=html&link=news1
  • Simple HTML Summary -- http://.../xmlcast.asp?out=shtmlsummary
  • Simple HTML Article -- http://.../xmlcast.asp?out=html&link=news1
Now, let's see how we output in RSS.

Next: Output as RSS
Sponsors

Search

Eliminate irrelevant hits with our industry-specific search engine!









Wireless Developer Network - A MindSites Group Trade Community
Copyright© 2000-2010 MindSites Group / Privacy Policy
Send Comments to:
feedback@wirelessdevnet.com