用PHP DOM HTML Parser替换多个值(新手)

Consider the following code stored in a database:

<section id="aids" data-toggle="collapse" data-target="#aids2" class="SecCon">
  <h2><span class="label label-primary"><small><span class="only-collapsed glyphicon glyphicon-chevron-down"></span><span class="only-expanded glyphicon glyphicon-remove-sign"></span></small> Aids</span></h2>
  <div id="aids2" class="collapse in article">
    <p>Some text.</p>
  </div>
</section>

I'd like to change it to this simpler format:

<section id="directions">
  <h2>Directions</h2>
  <div><p>Some text.</p></div>
</section>

<section id="ecology">
  <h2>Ecology</h2>
  <div><p>Some text.</p></div>
</section>

This is the code I'm really focusing on. I'm going to manually insert a unique ID for every section, and every header with also have a unique title, of course.

<section id="SomeValue">
  <h2>Another Value</h2>
  <div>

Before a user can use jQuery to toggle an element open or closed, data-target and div id have to have matching values. I discovered several problems when modifying the header or section ID to form these "secondary ID's." So I think it would be better if they simply consisted of lower case sequential letters (a, b, c, etc.)...

<section data-target="#a">
  <h2></h2>
  <div id="a">

<section data-target="#b">
  <h2></h2>
  <div id="b">

I was trying to figure out how to do this with regex but was advised that HTML DOM Parser is better. So I downloaded the files from http://simplehtmldom.sourceforge.net/ and started playing with it.

I can do some very simple exercises, but I haven't figured out how to do this project yet. At best, I can change just one element at a time.

I have a database query that that extracts an article from my database as $Content. If I wanted to replace "zebra" with "aardvark," I'd do this:

$Content = str_replace('zebra', 'aardvark', $Content);
echo $Content;

How do I plug in this HTML parser so all the classes, sequential divs and glyphicons are added to the mix?

phpQuery is very good at this kind of manipulations