How to read the HTML file??

Discussion in 'PHP' started by eshban, Dec 9, 2006.

  1. eshban

    eshban New Member

    Joined:
    Dec 6, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello,

    Iam facing a small problem in PHP.

    I have some html code like

    HTML:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    
    <table width="80%" border="1">
      <tr>
        <td><img src="Image1.jpg" width="18" height="18" /></td>
        <td><img src="Image2.jpg" alt="sad" width="18" height="18" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
    
    
    I want to make a small script which reads all the contents of this HTML CODE under the "BODY" tag and replaces all the "src=Image1" with my path which i had already stored in a Variable. Like after the script completion the path will be "images\Cat\ABC\image1.jpg"

    How can i do this. Plz help, because i tried it, but i am failed. Hope for a good response and suggestions

    THanks
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    You can you regex to replace it! Match the src attribute and replace it with whatever you want.
     
  3. eshban

    eshban New Member

    Joined:
    Dec 6, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Did you provide any source code which helps me
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice