0

I want to merge two different html files into one,

html1.html

<html>
  <head>
    <link href="blah.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <h1 id="logo">
        <span class="test1">Test text</span>    
    </h1>
  </body>
</html>

html2.html

<html>
  <head>
    <script src="blah.js"></script>
  </head>
  <body>
    <h1 id="logo">
       <span>Test text</span>
       <div class="test2">teststetset</div> 
    </h1>
  </body>
</html>

I want to take these two files and make a master file that would look like this:

<html>
  <head>
    <link href="blah.css" rel="stylesheet" type="text/css" />
    <script src="blah.js"></script>
  </head>
  <body>
    <span class="test1">Test text</span>
    <div class="test2">teststetset</div>
  </body>
</html>

I want to know is this possible using php or any library or using Linux command?

Turn
  • 45
  • 1
  • 9
  • 1
    Because anything like this would have to be very rule specific you'd have to write something that would adhere to *your* rules for the merge. – Jay Blanchard Aug 03 '15 at 12:03
  • refer this: http://stackoverflow.com/questions/12294120/how-to-embed-html-files-in-php-code – Insane Skull Aug 03 '15 at 12:06
  • 2
    Aside from doing this manually in a text editor, the primary tool you're looking for is likely just going to be a DOM parser. You'd read the structures of the two HTML documents into memory and then perform your merge logic on them, producing the output document. How you *define* that merge logic is up to you. – David Aug 03 '15 at 12:07

0 Answers0