Given this XML/XHTML snippet:
<h1>
<zuq:data name="siteHeader" />
</h1>
<h2>
<zuq:data name="pageHeaderName" />
<span>—</span>
<zuq:data name="pageHeaderTitle" />
</h2>
I've used SimpleXML's XPath method to round up all top-level nodes in the zuq namespace. Since the array elements of the xpath() method are pseudo references to the SimpleXML object tree nodes, I figured manipulation would be easy. However, I cannot figure out how to replace a given element node with a text node. How could I, for example, replace <zuq:data name="siteHeader" /> with the text My Site Header.
I've considered simply targeting the parent node and modifying it's contents as could work with the first block (<h1>), but I don't see that working given the case of my second block (<h2>).
Is there an easy way to replace a given element node with a text node via SimpleXML in PHP?