Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Representing Lengths in XML files

Status
Not open for further replies.

bernardmanning

Programmer
Oct 14, 2003
61
GB
Hi,

Could anybody tell me which is the way to write lengths out in XML files.

I have a requirement to output units of lengths in both metric and imperial, ie millimeters and feet inches and fraction of inches.

Has anybody got any pointers as to the various methods of achieving this?

Thanks, Berny

 
<soapbox>
For the record, this is a bad idea. If you're storing data, it will become internally inconsistent: count on it. If you're transferring data, you're wasting bandwidth. The right way to do this is to decide which measurement system you will use internally and provide methods to do the required conversions for the user.
</soapbox>

You could do something like this:
Code:
<widget>
  <length>
    <metric>
      <qty>450
        <unit>mm</unit>
      </qty>
    </metric>
    <imperial>
      <qty>15
        <unit>feet</unit>
      </qty>
      <qty>5.72
        <unit>inches</unit>
      </qty>
    </imperial>
  </length>
</widget>

Ack! This is ugly. Stick with metric and do conversions where needed. Good luck.
 

Hi HareBrain,

Thanks for the reply,

Yes, I agree with you about bandwidth and conversion factors etc, however the fact that I need to export both metric and imperial is out of my control :(

Again , thanks for the reply, Bernard


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top