What is common practice given the two xml formats? And how would you go about converting the first to the second format, regex? Should I have <subgroupones> there at all? Basically any <tags> that have no attributes except <global> should be deleted or if there is a more elegant way.
<global>
<groupone name="bce">
<subgroupones>
<subsgroupone name="a" />
<subsgroupone name="b" />
<subsgroupone name="c" />
</subgroupones>
<groupone>
</global>
<global>
<groupone name="bce">
<subsgroupone name="a" />
<subsgroupone name="b" />
<subsgroupone name="c" />
<groupone>
</global>
XML to XML conversion is almost always best handled by Stylesheet Transform (XSLT). PHP has built-in libraries for handling XSLT: http://php.net/manual/en/book.xslt.php
For example, here’s an XSLT that will copy only elements that have attributes (with the exception of
<global>which is always included):Sample output (not sure yet how to remove that excess space):
You can experiment with this tool: http://xslttest.appspot.com/