Using XML for report downloads

Sphexi

Diamond Member
Feb 22, 2005
7,280
0
0
Just a quick question/opinion poll on how to use XML.

My company has programmed a new reporting API for our clients to use, it offers fairly flexible functionality as far as you can submit query strings or XML to it, receive back either, it pulls multiple reports, etc.

One of the reports though spits back XML using tag attributes for the row info, such as this:

Code:
<row header1="data" header2="data2" header3="data3"></row>
I know that it could be done like this instead:

Code:
<row>
   <header1>data</header1>
   <header2>data2</header2>
   <header3>data3</header3>
</row>

My question is, are either of these methods considered "preferred" or "proper", or are both fine to use? We fully documented the usage of this API, and since it's new we haven't broken anybody's setup by providing it like this, but we have a single client who's complaining about it and escalating to try and get us to fully re-do it to their liking.
 
Last edited:

Oyster

Member
Nov 20, 2008
151
0
0
A very simple rule to keep in mind when differentiating between elements and attributes: attributes provide complementary metadata for the element. The rule is not written in stone, but it usually makes sense most of the time. An example where this rule may be deemed ambiguous - XML describing people.

You could have:
Code:
<Person ID="1">
  <Name>Jose</Name>
</Person>

Or:
Code:
<Person>
  <ID>1</ID>
  <Name>Jose</Name>
</Person>

If it were up to me, I'd go with the second option.

In your case, a header doesn't describe a row. So I would lean towards the second option, too. Another rule I use is to keep in mind the after-effects of using too many attributes. If you have a 100 headers, how do you think the resulting XML is going to look like if you were using only attributes? Ugly!

Again, these are my opinions, and most of the XML I have come across is primarily element-heavy. So my "rules" may be skewed. It'd be interesting to see what others do.
 

Sphexi

Diamond Member
Feb 22, 2005
7,280
0
0
Honestly I've googled this quite a bit, and haven't really been able to find many examples of option 1 being done. I suppose it could have been done so we could just import other reports in the future without any extensive coding being done, but it doesn't make much sense.

Then again I wasn't involved in the design/coding aspect of it, I'm just a support person who has to explain to clients the madness that is our system
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
I expose our web API via a RESTful Ruby on Rails service and the following is example of the XML it generates.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<sub-profiles type="array">
  <sub-profile>
    <id type="integer">2</id>
    <name>Testing</name>
    <login-ip>10.0.4.130</login-ip>
    <last-request-at type="datetime">2011-01-11T17:48:30Z</last-request-at>
    <is-active type="boolean">true</is-active>

  </sub-profile>
</sub-profiles>
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |