Results 1 to 4 of 4

Thread: [2005] Adding lines to html

  1. #1

    Thread Starter
    Lively Member esafwan's Avatar
    Join Date
    Apr 2008
    Location
    Bangalore-India
    Posts
    95

    Question [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

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    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()

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4

    Thread Starter
    Lively Member esafwan's Avatar
    Join Date
    Apr 2008
    Location
    Bangalore-India
    Posts
    95

    Resolved 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
  •  



Click Here to Expand Forum to Full Width