0

Traditionally, I've used XML like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "example.dtd">
<log>
    <record>
        <date>2014-05-16T17:58:52</date>
        <level>INFO</level>
        <message>This is the English stuff to present to humans.</message>
    </record>
    <record>
        <date>2014-05-16T17:59:00</date>
        <level>FINE</level>
        <message>Core crashed. Attempting smooth restart...</message>
        <exception>
            <message>Concurrent Modification Exception</message>
            <frame>
                <class>java.util.ArrayList$Itr</class>
                <method>checkForComodification</method>
                <line>859</line>
            </frame>
            <frame>
                <class>java.util.ArrayList$Itr</class>
                <method>next</method>
                <line>831</line>
            </frame>
            <frame>
                <class>com.name.app.Main$3</class>
                <method>run</method>
                <line>120</line>
            </frame>
            <frame>
                <class>java.lang.Thread</class>
                <method>run</method>
                <line>744</line>
            </frame>
        </exception>
    </record>
</log>

But recently I've learned Android and how they do XML, and fell in love with this format:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "example2.dtd">
<log>
    <record
        date="2014-05-16T17:58:52"
        level="INFO"
        message="This is the English stuff to present to humans."/>
    <record
        date="2014-05-16T17:59:00"
        level="FINE"
        message="Core crashed. Attempting smooth restart...">
        <exception
            message="Concurrent Modification Exception">
            <frame
                class="java.util.ArrayList$Itr"
                method="checkForComodification"
                line="859"/>
            <frame
                class="java.util.ArrayList$Itr"
                method="next"
                line="831"/>
            <frame
                class="com.name.app.Main$3"
                method="run"
                line="120"/>
            <frame
                class="java.lang.Thread"
                method="run"
                line="744"/>
        </exception>
    </record>
</log>

Is either of these better than the other? Is one more encouraged, or is another parsed faster? What are any advantages or disadvantages, or is it only preference?

Ky.
  • 28,753
  • 48
  • 180
  • 285
  • If this is solely up to preference, I prefer the second, simply because it looks easier to read once highlighted. – Ky. Dec 07 '14 at 01:41
  • 1
    There are lots of answers handling this question. For example you might start with reading http://stackoverflow.com/questions/33746 – Uli Feb 09 '15 at 20:13

0 Answers0