A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Tricky problem: change the tag name based on its attribute and value

  1. #1
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171

    Question Tricky problem: change the tag name based on its attribute and value

    Tricky problem (I think):
    I want to change the tag with a specific attribute and value: <div class="THD"> to <h1 class="THD">.
    The closing <\div> tag belonging to the respective tag also needs to change.

    Does anyone know about a tool that can help me do that (without much manual editing).

    I have a large html document structured like this (simplified):

    Code:
    <div class="MAIN" id="B01-C1">
    <div class="CHSO">
    <div class="THD">
    <div class="HNUM">Chapter 11</div>
    <div class="HD">Freedom</div>
    </div>
    </div>
    <a name="PG72"> </a><div class="page"><div>P.53</div></div><br clear="all">
    <div class="TBD">
    <div class="TLV1" id="B0142943">
    <div class="HD">OVERVIEW/div>
    <div class="P">Aung San Suu Kyi, the Burmese democracy leader, called for a “non-violent revolution” today as she began the task of re-establishing herself as the leader of a political party after seven years of house arrest.</div>
    </div>

  2. #2
    Senior Member
    Join Date
    Sep 2010
    Posts
    324
    DreamWeaver and NotePad++ (plus most regular word processors) have a text editing feature called "Find and Replace"... would run thru the page pretty quick.
    Video Man

  3. #3
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    That won't work because if you replace all the <\div> tags the syntax will no longer be right.

    I have tried using regular expression, but found no text editor that supports variables in the output.

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Dreamweaver's Find and Replace does let you get specific enough to do this. You can say "Find specific tag <div> with class "THD", replace tag with <h1>"

  5. #5
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171

    Thumbs up

    You made my day

  6. #6
    Senior Member somlemeg's Avatar
    Join Date
    Aug 2000
    Posts
    171
    On a large document Dreamweaver search replace for tags is slow, do you know of any alternative program? Checked out Notepad++, but it does not seem to have the search and replace tags function.
    Last edited by somlemeg; 11-21-2010 at 05:58 AM.

  7. #7
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Is it slower than posting a question here and waiting for us to get back to you?

    Dreamweaver is what I use, maybe someone else will chime in for you.

  8. #8
    Junior Member
    Join Date
    Dec 2010
    Location
    United States
    Posts
    10

    Tricky problem: change the tag name based on its attribute and value

    Use dreamweaver for Find and Replace does let you get specific enough to do this.

Tags for this Thread

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

HTML5 Development Center