Hi Group-

I've text I'm reading in (via a recordset) which looks like this:
RAP:HalletHall:Single
RAP:HalletHall:Double
LLE:FarrandHall:Single

It will always have 3 columns and delimited with a ":". In the end, it
needs to be an <ul> in HTML:
<ul>
<li>RAP
<ul>
<li>HalletHall
<ul>
<li>Single</li>
<li>Double</li>
</ul>
</li>
</ul>
</li>
<li>LLE
<ul>
<li>FarrandHall
<ul>
<li>Single</li>
</ul>
</li>
</ul>
</li>
</ul>


Any ideas how to parse this data and transform it to properly formatted
HTML using vbscript?

I've tried splitting the data into a multi-dimensional array, but can't
wrap my mind around this programatically. All insights appreciated!

e
__________________________________
Eric R. Den Braber
Housing IT
University of Colorado - Boulder




*** Sent via Developersdex http://www.developersdex.com ***

Re: transform delimited rs to unordered list in html by JHP

JHP
Thu Sep 15 12:18:47 CDT 2005

This by no stretch of the imagination will work as is - but it may give you
an idea of an approach:

Option Explicit
On Error Resume Next

Const forWriting = 2
Const createFile = True

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Test.html", forWriting, createFile)

...

bldFile = "<ul>" & vbCRLF
rs.MoveFirst
rtnArray1 = Split(rs.Value, ":")
rs.MoveNext
rtnArray2 = Split(rs.Value, ":")

Do
bldFile = bldFile & vbTab & "<li>" & rtnArray1(0) & vbCRLF
bldFile = bldFile & vbTab & vbTab & "<ul>" & vbCRLF
bldFile = bldFile & vbTab & vbTab & vbTab & "<li>" & rtnArray1(1) & vbCRLF
bldFile = bldFile & vbTab & vbTab & vbTab & vbTab & "<ul>" & vbCRLF
bldFile = bldFile & vbTab & vbTab & vbTab & vbTab & vbTab & "<li>" &_
rtnArray1(2) & "</li>" & vbCRLF

Do
If rtnArray1(0) & rtnArray1(1) = rtnArray2(0) & rtnArray2(1) Then
bldFile = bldFile & vbTab & vbTab & vbTab & vbTab & vbTab & "<li>" &_
rtnArray2(2) & "</li>" & vbCRLF
rs.MoveNext

If Not rs.EOF Then
rtnArray1 = rtnArray2
rtnArray2 = Split(rs.Value, ":")
End If

Else
bldFile = bldFile & vbTab & vbTab & vbTab & vbTab & "</ul>" & vbCRLF
bldFile = bldFile & vbTab & vbTab & vbTab & "</li>" & vbCRLF
bldFile = bldFile & vbTab & vbTab & "</ul>" & vbCRLF
bldFile = bldFile & vbTab & "</li>" & vbCRLF
rs.MoveNext

If Not rs.EOF Then
rtnArray1 = rtnArray2
rtnArray2 = Split(rs.Value, ":")
End If
Exit Do
End If
Loop Until rs.EOF
Loop Until rs.EOF
bldFile = bldFile & "</ul>"
objFile.Write bldFile
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing

"eric db" <mr_ericdbSPAMMERS@HAVEMERCYyahoo.com> wrote in message
news:ekTSfMXuFHA.3752@TK2MSFTNGP09.phx.gbl...
> Hi Group-
>
> I've text I'm reading in (via a recordset) which looks like this:
> RAP:HalletHall:Single
> RAP:HalletHall:Double
> LLE:FarrandHall:Single
>
> It will always have 3 columns and delimited with a ":". In the end, it
> needs to be an <ul> in HTML:
> <ul>
> <li>RAP
> <ul>
> <li>HalletHall
> <ul>
> <li>Single</li>
> <li>Double</li>
> </ul>
> </li>
> </ul>
> </li>
> <li>LLE
> <ul>
> <li>FarrandHall
> <ul>
> <li>Single</li>
> </ul>
> </li>
> </ul>
> </li>
> </ul>
>
>
> Any ideas how to parse this data and transform it to properly formatted
> HTML using vbscript?
>
> I've tried splitting the data into a multi-dimensional array, but can't
> wrap my mind around this programatically. All insights appreciated!
>
> e
> __________________________________
> Eric R. Den Braber
> Housing IT
> University of Colorado - Boulder
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***