7

<!-- Comment --> is the way to add comments in an XML file. Doesn't that actually means, that this part is not "compiled"?

However, when I do something like this:

<item android:id="@+id/ss3"
    android:icon="@drawable/some_icon"
    android:title="Blabla Title"
    tools:ignore="AppCompatResource"
    <!-- -->
/>

I get an error "Tag start is not closed". Why?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
user3801167
  • 177
  • 1
  • 2
  • 7

1 Answers1

6

Comments are not allowed inside tags. You have to close the tag first with ">" or "/>" and then you can add your comment there.

Miro Lehtonen
  • 609
  • 6
  • 18
  • Ah ok thanks. Pretty stupid if you ask me.. I mean you should be able to add a comment wherever you like. I just don't see the point in that 'rule'. – user3801167 Sep 07 '14 at 21:43
  • 2
    If you want to understand why XML is the way it is, you need to understand the history of SGML. I'm no expert, but the basic story is that SGML allowed a vast amount of syntactic variety, far more than anyone needed, and as a result it was difficult and expensive to parse. XML came about from an exercise in reducing SGML to a vastly simpler syntax that removed everything inessential. – Michael Kay Sep 07 '14 at 23:30