Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Comment Inside Element

Tags:

xml

In the following XML, what is the alternative way to place a comment over the attributes of element?

  <!-- I can comment here -->

  <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/textView_ben"

        <!-- Cannot place a comment here  -->

        android:layout_centerHorizontal="true"/>
like image 513
user103214 Avatar asked Jul 30 '16 13:07

user103214


People also ask

How do I comment out an element in XML?

An XML comment encountered outside the document type declaration is represented by the Comment value syntax element. It contains the comment text from the XML message. If the value of the element contains the character sequence --> , the sequence is replaced with the text --&gt; .

How do you add a comment in XML?

Syntax. A comment starts with <! -- and ends with -->. You can add textual notes as comments between the characters.

Does XML allow commenting elements?

Allows notes and other human readable comments to be included within an XML file. XML Parsers should ignore XML comments. Some constrains govern where comments may be placed with an XML file.

Can comments be nested in XML?

No, the string -- is not permitted to appear within comments in XML. So the fact you have -- show up inside another comment is going to cause failures.


1 Answers

No, this isn't possible. Comments are not allowed in an XML open tag.

See How do I comment attributes inside an XML tag?

like image 164
DAB Avatar answered Nov 26 '22 11:11

DAB