SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Rochester, NY
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Rip & mix XHTML documents?

    I wrote a ton of web pages with the same body structure but slightly different code in the header and footer. I'd like to standardize them to all be the same.

    What I need to do is extract everything inside <div id="authored-area">...</div> and put it in a new template. I also need this to be automated, because I have a couple hundred pages. Would anyone know where to start?

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need a text editor that supports regular expressions - then you can write a little piece of code to do that.


  3. #3
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Rochester, NY
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That was one of the first things I thought of, but I couldn't figure out how it would work. The reason is that there are nested divs, and so I can't figure out where the correct closing </div> is. Is there a way?

  4. #4
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes - definitely! I'm not very good at this sort of stuff, so I can't help you with code, but I've seen it done - basically, with regular expressions you can find <div id="authored-area"> and tell the program to delete everything from the end of that string to the start of the first </div> it comes across... and bingo! Wish I could show you the code - but I bet a bit of Googling will help at this point...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •