rbutterwood
Programmer
What are the downside of using attributes over extra elements. Several books state that it is purely down to the designer's personal preference on using attributes or elements.
Personally I think that attributes are nicer as it doesn't bloat the xml.
Here are two examples with and without attributes. Which is best?
With Attributes
<RequestBatch ConsumerKey="..." Password="..." Language="..." DateTime="..." SerialID="...">
<Request RequestID="..." Company="..." SerialID="...">
...
</Request>
</RequestBatch>
Without Attributes
<RequestBatch>
<Authentication>
<ConsumerKey>...</ConsumerKey>
<Password>...</Password>
<Language>...</Language>
<DateTime>...</DateTime>
</Authentication>
<Request>
<RequestHeader>
<RequestID>...</RequestID>
<Company>...</Company>
<SerialID>...</SerialID>
</RequestHeader>
...
</Request>
</RequestBatch>
Personally I think that attributes are nicer as it doesn't bloat the xml.
Here are two examples with and without attributes. Which is best?
With Attributes
<RequestBatch ConsumerKey="..." Password="..." Language="..." DateTime="..." SerialID="...">
<Request RequestID="..." Company="..." SerialID="...">
...
</Request>
</RequestBatch>
Without Attributes
<RequestBatch>
<Authentication>
<ConsumerKey>...</ConsumerKey>
<Password>...</Password>
<Language>...</Language>
<DateTime>...</DateTime>
</Authentication>
<Request>
<RequestHeader>
<RequestID>...</RequestID>
<Company>...</Company>
<SerialID>...</SerialID>
</RequestHeader>
...
</Request>
</RequestBatch>