Results 1 to 3 of 3

Thread: html to xhtml

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    11

    html to xhtml

    I would like to build a program that would go through a selected folder of .aspx source files and edit them based on the rules I defined in the program.

    I haven't really found a good way to get the document's data

    example of changes made
    <HTML> -> <html> i would like it loop through contents of file and change the uppercase tags to lowercase without changing the data inside the tags.

    I've looked at just using regex for this but i wanted to know if there where any html controls that would do this kinda thing.

    thanks for the help

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: html to xhtml

    As far as I know, there isn't an easy way to manipulate HTML in .Net. Having said that, you may want to just do a search for anything with a set of <> characters. Then, have your program create a list of items it's going to change so you can stop or edit certain ones before they're changed.

    If you're changing a large site, it's probably best to have a hand in any kind of conversions just in case.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    11

    Re: html to xhtml

    Dim strContents As String = stReader.ReadToEnd()
    stReader.Close()

    strContents = strContents.Replace("<HTML>", "<html>")
    strContents = strContents.Replace("<HEAD>", "<head>")
    strContents = strContents.Replace("</HEAD>", "</head>")
    strContents = strContents.Replace("<BODY", "<body")
    strContents = strContents.Replace("</BODY>", "</body>")
    strContents = strContents.Replace("<TR", "<tr")
    strContents = strContents.Replace("</TR>", "</tr>")
    strContents = strContents.Replace("<TD", "<td")
    strContents = strContents.Replace("</TD>", "</td>")
    strContents = strContents.Replace("<BR>", "<br/>")
    strContents = strContents.Replace("<BR />", "<br />")
    strContents = strContents.Replace("<TABLE", "<table")
    strContents = strContents.Replace("</TABLE", "</table")
    ' strContents.Replace("", "")
    strContents = strContents.Replace("</HTML>", "</html>")

    ' Dim stWriter As StreamWriter
    'stWriter = File.CreateText(strFileName)

    'stWriter =
    File.WriteAllText(strFilePath, strContents)
    txtContents.Text = strContents




    thats what i've come up with so far. just a note there are over 350 files

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