3

I'm currently developing a web-based XML managing program for a client (though I may 'market' it for future clients). Currently, it reads an XML document, converts it into manageable Javascript objects, and ultimately spits out indented, easy to read XML code. Edit: The program would be used by clients that don't feel like learning XML to add items or tags, but I (or another XML developer) may use the raw data for quick changes without using an editor.

I feel like fundamentally, its ready for release, but I'm wondering if I should go the extra mile and allow support for remembering (and perhaps making) comments before generating the resulting XML.

Considering that these XML files will probably never be read without a program interpreting it, should I really bother adding support for comments? I'll probably be the only one looking at raw files, and I usually don't use comments for XML anyway.

So, are comments common/important in most XML documents?

6
  • If XML was a simple data format, I'd agree that nobody needs to read them. But due to some perverse circumstances, people are writing programs in XML. That's not even mentioning lots of data that does not have a dedicated editor and is edited by hand.
    – user7043
    Mar 19, 2012 at 16:35
  • 1
    @delnan well, for the scope of this question, assume that people using this XML generating program intend on separating data from programming logic ;) Mar 19, 2012 at 16:40
  • 2
    It's impossible for anyone to answer a question about "most xml documents". There are millions -- if not 10's or 100's of millions -- of different types of xml documents. Apr 7, 2012 at 16:24
  • 1
    XML is an asset in your project. It should be described from a business and technical perspective adequately in your documentation. INMO, Adding comments within the XML file itself is rather useless if you already describe the document elsewhere.
    – NoChance
    Apr 7, 2012 at 16:47
  • Your title and actual question are two different things. The title asks, in essence "do others do this" but your question body asks "should I do this. Neither type of question really fits the format of this site. Jun 1, 2012 at 22:46

2 Answers 2

4

Considering that these XML files will probably never be read without a program interpreting it

Then what value is there in a program whose entire purpose is to produce "indented, easy to read XML code"?

I know that I've seen a lot of comments in XML configuration files (Java frameworks and the like). Pretty much none in data files.

The real question is who you expect to use the program and for what purpose. We can't answer that for you.

1
  • The program would be used by clients that don't feel like learning XML to add items or tags, but I (or another XML developer) may use the raw data for quick changes. So, easy to read is somewhat important. I'll update my OP. Mar 19, 2012 at 16:43
3

Comments are to make code more human readable. They should be used as such.

If your XML is going read by humans (ie config files) then comments are good. If they aren't then they are just bloat and should be left out.

2
  • I've always figured XML is (or should be) self documenting, though I haven't ever gone past using 15 or so unique tags. Do you see comments in purely data XML documents often? Apr 7, 2012 at 16:05
  • all that whitespace for pretty indentation is also bloat. Recently I was processing some documents that were fairly large (a gig or two if memory serves) and they were more than 50% insignificant whitespace. Apr 7, 2012 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.