title: SimpleXML: how to replace node name?
body: <p>I'm trying to output xml file as html. It seems like simpleXML processing is faster than XSL on my files (files are 2-3mb each). So I ended with simpleXML. Everything seems fine, files loaded ok with <code>$data = simplexml_load_string($file)</code> but now I need to replace node names with html tag names and build a new document with <code>$data-&gt;asXML()</code>.
  Is there any way to do this?</p>
  
  <p>What I have now:</p>
  
  <pre><code>    &lt;body&gt;
   &lt;section&gt;
    &lt;title&gt;
     &lt;p&gt;sometext&lt;/p&gt;
    &lt;/title&gt;
    &lt;epigraph&gt;
      &lt;p&gt;sometext&lt;/p&gt;
    &lt;/epigraph&gt;
    &lt;stanza&gt;
      &lt;v&gt;sometext&lt;/v&gt;
      &lt;v&gt;sometext&lt;/v&gt;
      &lt;v&gt;sometext&lt;/v&gt;
      &lt;v&gt;sometext&lt;/v&gt;
    &lt;/stanza&gt;
    &lt;stanza&gt;
      &lt;v&gt;sometext&lt;/v&gt;
      &lt;v&gt;sometext&lt;/v&gt;
      &lt;v&gt;sometext&lt;/v&gt;
      &lt;v&gt;sometext&lt;/v&gt;
    &lt;/stanza&gt;
     &lt;section&gt;
      &lt;title&gt;
       &lt;p&gt;sometext&lt;/p&gt;
      &lt;/title&gt;
      &lt;epigraph&gt;
        &lt;p&gt;sometext&lt;/p&gt;
      &lt;/epigraph&gt;
      &lt;stanza&gt;
        &lt;v&gt;sometext&lt;/v&gt;
        &lt;v&gt;sometext&lt;/v&gt;
        &lt;v&gt;sometext&lt;/v&gt;
        &lt;v&gt;sometext&lt;/v&gt;
      &lt;/stanza&gt;
      &lt;stanza&gt;
        &lt;v&gt;sometext&lt;/v&gt;
        &lt;v&gt;sometext&lt;/v&gt;
        &lt;v&gt;sometext&lt;/v&gt;
        &lt;v&gt;sometext&lt;/v&gt;
      &lt;/stanza&gt;
     &lt;/section&gt;
   &lt;/section&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>And I'd like to have this:</p>
  
  <pre><code>   &lt;body&gt;
   &lt;div class="section"&gt;
    &lt;h2&gt;
     &lt;span&gt;sometext&lt;/span&gt;
    &lt;/h2&gt;
    &lt;div class="epigraph"&gt;
      &lt;p&gt;sometext&lt;/p&gt;
    &lt;/div&gt;
    &lt;ul&gt;
      &lt;li&gt;sometext&lt;/li&gt;
      &lt;li&gt;sometext&lt;/li&gt;
      &lt;li&gt;sometext&lt;/li&gt;
      &lt;li&gt;sometext&lt;/li&gt;
    &lt;/ul&gt;
    &lt;ul&gt;
      &lt;li&gt;sometext&lt;/li&gt;
      &lt;li&gt;sometext&lt;/li&gt;
      &lt;li&gt;sometext&lt;/li&gt;
      &lt;li&gt;sometext&lt;/li&gt;
    &lt;/ul&gt;
     &lt;div class="section"&gt;
      &lt;h2&gt;
       &lt;span&gt;sometext&lt;/span&gt;
      &lt;/h2&gt;
      &lt;div class="epigraph"&gt;
        &lt;p&gt;sometext&lt;/p&gt;
      &lt;/div&gt;
      &lt;ul&gt;
        &lt;li&gt;sometext&lt;/li&gt;
        &lt;li&gt;sometext&lt;/li&gt;
        &lt;li&gt;sometext&lt;/li&gt;
        &lt;li&gt;sometext&lt;/li&gt;
      &lt;/ul&gt;
      &lt;ul&gt;
        &lt;li&gt;sometext&lt;/li&gt;
        &lt;li&gt;sometext&lt;/li&gt;
        &lt;li&gt;sometext&lt;/li&gt;
        &lt;li&gt;sometext&lt;/li&gt;
      &lt;/ul&gt;
     &lt;/div&gt;
   &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>thanks in advance</p>