views:

83

answers:

4

How can I do this task automatically. I need to change source order of the divs, which has same id in above 100 pages.

I created an example:

This is default condition

<div class="identification">  <div class="number">Number 1</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 4</div> </div>
<div class="identification">  <div class="number">Number 5</div> </div>
<div class="identification">  <div class="number">Number 6</div> </div>
<div class="identification">  <div class="number">Number 7</div> </div>

I need it like this

<div class="identification">  <div class="number">Number 1</div> </div>
<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
<div class="identification">  <div class="number">Number 7</div> </div>
<div class="identification">  <div class="number">Number 4</div> </div>
<div class="identification">  <div class="number">Number 5</div> </div>
<div class="identification">  <div class="number">Number 6</div> </div>

Is the manual editing only option? I use Dreamweaver.

I have to do this change in HTML source permanently.


Edit: (it's just example)

The fix things are, total div are 7 and every container div has same class="identification"

A: 

Well you could move it around using javascript, or you could delete list and replace it using javascript as well.

You can use jQuery detach(), remove() and append()/appendTo() methods for this kind of manipulation.

mr.b
I want to change in HTML Source permanently
metal-gear-solid
Sorry, it's not clear from your question that you have to change it in source code. That's a different story then.
mr.b
A: 

is it always the same number you need to replace? In dreamweaver you could do a find and replace in all files in a folder. Replace "Number 6" with "Number X" then replace "Number 4" with "Number 6" then finally replace "Number X" with "Number 4"

saves you writing a program to do it

DrLazer
No i need to move whole div. I just given example here.
metal-gear-solid
But divs are 7 this is fix
metal-gear-solid
+2  A: 

Breathe deep and start manual editing. Take pauses of 5 minutes on every 10 minutes to avoid that you get freaked out. You'll finish in a hour or two. At least, in less time than figuring the regex solution for this.

BalusC
@ I have to do in 100 - 150 files and source of files are very poorly formatted. I want to do like just open the file and play any macro/regex etc. but if no shortcut then will do manually.
metal-gear-solid
Yes I understand you. I've undergone the same horror. That's what you get paid for.
BalusC
@OP: either you parse the HTML and swap, or you do it by hand. As BalusC said, do it by hand: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
ANeves
+1  A: 

The easiest solution would be to do a single Find & Replace, searching for the entire menu as it is now, and replacing it with the entire menu as you want it to be. This ignores completely the actual changes ("I want to move this div up here and that one down there"), and gets the job done in one operation, covering all 100 pages.

Alternatively, you can do several smaller Find & Replace operations:

Replace <div class="identification"> <div class="number">Number 3</div> </div> with <div class="identification"> <div class="number">Number 6</div> </div>

Replace <div class="identification"> <div class="number">Number 2</div> </div> with two lines:

<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
VoteyDisciple
Every div has different content inside in all 100 pages.
metal-gear-solid