Thursday, 26 February 2015

Best practices for defining an XML document?



We're working on an XML schema which will be used to transfer data user profiles but I'm wondering what would be the best practice for defining such a schema in the first place, so as not to reinvent the wheel or come back around later to redo the whole thing.


Would it for example, be better to define a user as such:



<user>
<name>John Doe</name>
<department>IT</department>
<phone type="home">12345678</phone>
<address type="home">
<road>5th Avenue</road>
<city>New York</city>
<state>New York</state>
<country>United States</country>
</address>
</user>


or would it be more efficient/better to define certain parts inside the tag, as such:



<user>
<name department="IT" phone="12345678" country="USA">John Doe</name>
<phone type="home">12345678</phone>
<address type="home">
<road>5th Avenue</road>
<city>New York</city>
<state>New York</state>
</address>
</user>


I am hoping my question isn't too ambiguous or vague, but what would be the best practice in this case? Or how is this done in most usage cases?


No comments:

Post a Comment