Results 1 to 2 of 2

Thread: [RESOLVED] replacing text in HTML-encoded paragraph

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Resolved [RESOLVED] replacing text in HTML-encoded paragraph

    Hi all.

    I am trying to do a simple text replace for a paragraph of text that is HTML-encoded.

    So, the first method is to simply use Replace(). That fails because the text is HTML-encoded. So in this example:

    <p class=MsoNormal style='text-indent:18.0pt'><span lang=EN-US
    style='font-size:9.0pt;font-family:Verdana'>Middle class families' income is
    much higher than the average level in </span><span lang=EN-US style='font-size:
    9.0pt;font-family:Verdana'>Sichuan</span><span lang=EN-US style='font-size:
    9.0pt;font-family:Verdana'> province. In 2003, the average income of middle
    class families reached 76,000 RMB, 3.65 times the average families' income of
    20,850 RMB.&nbsp; </span></p>

    If I try to replace the word income with <B>income</B>
    it will be okay. But if I try to replace the word 'class' with <B>class</B>,
    it will crash the data, replacing the HTML class too. So this method doesn't work.

    2nd method. I moved the Replace function into Javascript. Then I put the article text into a TD. I tried to use obj.innerText to do the replace on, but for some reason it did not do the replace. When I switched to .innerHTML, it works, but with the same problem.

    I need to distinguish what is <html> and what isn't .

    OK. I guess I see what has to be done now. (Just came to me). I need to use a regular expression to split the text into <dfsd> and non <dfds>. Then I do the replace on all non <edfds> and then join it back together. Right?

    Or do you have a better way?

    Thanks
    Wengang
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

  2. #2

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Re: replacing text in HTML-encoded paragraph

    ok this problem has evolved into a different problem. i"ll repost
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

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