So, i am developing a php/mysql/'ajax' application for one of our clients, and I have been trying to figure out how to style the xml that the php is returning. To make a long story short, I have been completely unable to do it via any simple way. So, I am having the php script return already well formed html, and then using a javascript function to walk through the xml, converting each node into its html equivalent. There has to be an easier way, but i will be damned if could find it.

function rebuildTags(n) {
var result;
if (n.nodeType == 1)
result = document.createElement(n.nodeName);
else if(n.nodeType == 3)
result = document.createTextNode(n.nodeValue);
var children = n.childNodes;
for(var i=0; i < children.length; i++) {
result.appendChild( rebuildTags(children[i]));
}
return result;
}


ok so here is the skinny: I have a single php script that handles both the displaying of the html and the creation of the xml, it is all based on what $_POST variables are set. When you submit one of the forms on the page (there are 4), first, a javascript function kills that event, so that you stay on the page. The same javascript then submits the rebuilt http/post statement to the same .php script and then waits for the returned xml (it is asynchronus). This is an exmaple of what the script sends back

<div>
<h3>studio tomi added.</h3>
<ul>
<li><strong>parent company</strong>: studio tomi</li>
<li><strong>Address</strong>:
<ul>
<li>na</li>
<li>austin tx, 78701</li>
<li>United States of America</li>
</ul>
</li>
<li>miah@studiotomi.com</li>
<li>5126569016</li>
<li>85858585</li>
</ul>
</div>

Well formed html, well it looks like it, however xml documents have no style associated with them. And that is where the problem lies, getitng the information to render correctly. I am sure that there has to be an easy way to apply a style to an island of xml in an html document, I just couldn't find it. So the next best thing was to convert the xml nodes into html nodes, and the easiest way to do that was to not have to worry about what type of node it needed to be, hence the wellformed html.