<p>Imagine I have the folling XML file:</p>

<p>&lt;a&gt;before&lt;b&gt;middle&lt;/b&gt;after&lt;/a&gt;</p>

<p>I want to convert it into something like this:</p>

<p>&lt;a&gt;beforemiddleafter&lt;/a&gt;</p>

<p>In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv ./directory/* .", but for xml nodes.</p>

<p>I'd like to do this in using unix command line tools. I've been trying with xmlstarlet, which is a powerful command line XML manipulator. I tried doing something like this, but it doesn't work</p>

<p>echo "&lt;a&gt;before&lt;b&gt;middle&lt;/b&gt;after&lt;/a&gt;" | xmlstarlet ed -m "//b/*" ".."</p>

<p>Update: XSLT templates are fine, since they can be called from the command line.</p>

<p>My goal here is 'remove the links from an XHTML page', in other words replace where the link was, with the contents of the link tag.</p>

In XSLT, you could just write:
```
```
<xsl:template match="a"><a><xsl:apply-templates /></a></xsl:template>

<xsl:template match="a/b"><xsl:value-of select="."/></xsl:template>
```
```
And you'd get:
```
```
<a>beforemiddleafter</a>
```
```
So if you wanted to do this the easy way you could just create an XSL stylesheet and run your XML file through that.
I realise this isn't what you said you'd like to do (using Unix command line), however. I don't know anything about Unix, so maybe someone else can fill in the blanks, eg. some sort of command line calls that can execute the above.