One option would be to use the xslt task to do the heavy lifting. For example, generate a second ant script and invoke it.
build.xml:
<project default="mkdirs">
<target name="mkdirs">
<xslt style="mkdir.xslt" in="dirs.xml" out="mkdir.build.xml"/>
<ant antfile="mkdir.build.xml"/>
</target>
</project>
Place mkdir.xslt in the same directory as build.xml:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="text()"/>
<xsl:template match="root">
<project><xsl:text> </xsl:text>
<xsl:apply-templates/>
</project>
</xsl:template>
<xsl:template match="*">
<mkdir>
<xsl:attribute name="dir">
<xsl:for-each select="ancestor::*">
<xsl:if test="position() != 1">
<xsl:value-of select="name()"/>
<xsl:text>/</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:value-of select="name()"/>
</xsl:attribute>
</mkdir><xsl:text> </xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:transform>
Example mkdir.build.xml output from the xslt task:
<?xml version="1.0" encoding="UTF-8"?><project>
<mkdir dir="folder1"/>
<mkdir dir="folder1/folder1-1"/>
<mkdir dir="folder2"/>
<mkdir dir="folder3"/>
<mkdir dir="folder3/folder3-1"/>
</project>
I'm not fluent in XSLT, so it might be possible to improve on the for-each loop.