I think I'd need to see more of your data to answer that conclusively. I wrote up a little test script (if only to keep my own sanity, hehe), and that showed me I did get the attribute names according to how I understand your data. Let me know where your real stuff differs.
use XML::Simple;
$data = XMLin( \*DATA, KeepRoot => 1 );
@attrs = map { keys %{ $_->{attributes}{attribute} } }
values %{ $data->{dataschemas}{dataschema} };
print "@attrs";
__DATA__
<dataschemas>
<dataschema name="varyingName1">
<attributes>
<attribute>
<one>1</one>
<two>2</two>
</attribute>
</attributes>
</dataschema>
<dataschema name="varyingName2">
<attributes>
<attribute>
<three>3</three>
<four>4</four>
</attribute>
</attributes>
</dataschema>
</dataschemas>
Prints: one two three four |