Results 1 to 4 of 4

Thread: Removing Code from a text file.

  1. #1

    Thread Starter
    Lively Member smilbuta's Avatar
    Join Date
    Apr 2005
    Location
    Orlando
    Posts
    104

    Removing Code from a text file.

    HEllo community, I have an odd question.

    THis is a VB question because i want to automate this procedure with an app.
    Import text file.. Strip.. then save striped version..

    I have to format some HTML code by stripping out the script sections...


    For example..This is what i have

    Code:
    <html>
    <body> yadda
    <script> yadda yadda
    </Script>
    <br>
    <script> yadda yadda
    </Script>
    </body>
    </html>
    THis is what i want...

    Code:
    <html>
    <body> yadda
    <br>
    </body>
    </html>
    Im seeking help on the logic used to parce through the text file removing the scripting elemets as it finds them...
    VB.Net uber-noob since04, Yeababy!

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

    Re: Removing Code from a text file.

    Well, you can use some Regex to find the tags or you could just use the IndexOf method of a string to find it.

    Pseudo Code:
    Code:
    Integer First = 0, Second = 0
    First = MyText.IndexOf(0, "<script>")
    Second = MyText.IndexOf(First, "</script>")
    MyText = MyText.Remove(First, Second)
    Adjust and repeat as necessary.
    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
    Lively Member smilbuta's Avatar
    Join Date
    Apr 2005
    Location
    Orlando
    Posts
    104

    Re: Removing Code from a text file.

    SO i can put that in a loop as it finds each start script tag <script> then execute the code as it parces through the document...?
    VB.Net uber-noob since04, Yeababy!

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

    Re: Removing Code from a text file.

    Quote Originally Posted by smilbuta
    SO i can put that in a loop as it finds each start script tag <script> then execute the code as it parces through the document...?
    Yup. Put it in a loop and when it find a start and the next tag (the ending tag), kill it, and loop again.
    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

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