I am using PHP and SimpleXML and was wondering which will be faster and use less memory. I am not concerned with element vs attribute, but more on the perforance with PHP. There are 10 departments and 20 different categories. A file can belong to multiple departments and categories.
<file dep1="1" dep2="1" dep3="0" cat1="0" cat2="0" cat3="1" path="\path\to\file">
file description
</file>
or
<file path="\path\to\file">
<departments dep1="1" dep2="1" dep3="0" />
<categories cat1="0" cat2="0" cat3="1" />
<description>file description</description>
</file>
Performance will be pretty much equal. Attribute nodes and element nodes in a DOM are basically the same data structure, they are derived from the same base class, the will perform the same.
The point is more: What XML structure matches your data. That’s the one you should use.
I’d tend to use something like this, this feels most natural to me: