Given an xml block of:
How might I use xpath to re
With just XPath, you can't.
XPath allows you to query (select) nodes from an XML document tree, but it can't modify a tree or create new nodes. So if you select the original
node, it will have two
children, and you can't change that. In order to get a
with only one child, you'd have to either modify the original
to delete its other child, or create a new
.
You could do this with XSLT, as you alluded to; or a number of other XML tree-building technologies. If you tell us what kind of platform you're building on, we could suggest ones that are most relevant to your platform.