|
-
Feb 4th, 2009, 01:35 PM
#1
Thread Starter
Lively Member
[2005] Adding lines to html
Hi..I'm making an app that loads external html in a webbrowser after adding some value to it from a database. But how do i add the values.
the html will be somewhat like this
HTML Code:
<html>
<head>
<body>
<div id="wrapper">
<div id="heading">@</div>
<div id="content"><span class="line">$</span> </div>
</div>
</body>
</html>
I have to put the heading from Database replacing '@' sign
and content retrieved from db replcaing '$' sign.
There is one more important thing...the second div that is
Code:
<div id="content"><span class="line">$</span> </div>
will be in a loop... so i will have to put it n number of time depending on the loop...
How can i do that?!!
Men have become the tools of their tools. - Henry David Thoreau
-
Feb 4th, 2009, 02:36 PM
#2
Re: [2005] Adding lines to html
I dont completely understand your situation but I would be inclined to create the HTML in code, rather than doing text substitutions. In which case something like this;
Code:
Dim w As New System.IO.StreamWriter("YourFile.html")
w.WriteLine("<html>")
w.WriteLine("<head>")
w.WriteLine("<body>")
w.WriteLine("<div id=""wrapper"">")
w.WriteLine("<div id=""heading"">" & YourHeadingText & "</div>")
For i As Integer = 0 To n
w.WriteLine("<div id=""content""><span class=""line"">" & TextForItem_n & "</span> </div>")
Next
w.WriteLine("</div>")
w.WriteLine("</body>")
w.WriteLine("</html>")
w.Close()
-
Feb 4th, 2009, 02:55 PM
#3
Re: [2005] Adding lines to html
Do you want to replace all @'s and $'s with the same two strings? If you do, you could do something like this:
Code:
Private Sub MySubroutine()
Dim html As String = "<html><head><body><div id=""wrapper""><div id=""heading"">@</div><div id=""content""><span class=""line"">$</span></div></div></body></html>"
html = System.Text.RegularExpressions.Regex.Replace(html, "@|\$", New System.Text.RegularExpressions.MatchEvaluator(AddressOf MyMatchEvaluator))
End Sub
Private Function MyMatchEvaluator(ByVal m As System.Text.RegularExpressions.Match) As String
If m.Value.Equals("@") Then
Return "[The @ used to be here]"
Else
Return "[The $ used to be here]"
End If
End Function
-
Feb 5th, 2009, 10:27 AM
#4
Thread Starter
Lively Member
Re: [2005] Adding lines to html
thnx it worked...was a bit busy couldnt reply!11
Men have become the tools of their tools. - Henry David Thoreau
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|