fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

Is there any practical difference in these two forms of XML?
<person> <firstName>John</firstName> <lastName>Smith</lastName> <age>25</age> <address> <streetAddress>21 2nd Street</streetAddress> <city>New York</city> <state>NY</state> <postalCode>10021</postalCode> </address> <phoneNumbers> <phoneNumber type="home">212 555-1234</phoneNumber> <phoneNumber type="fax">646 555-4567</phoneNumber> </phoneNumbers> </person> <person firstName="John" lastName="Smith" age="25"> <address streetAddress="21 2nd Street" city="New York" state="NY" po +stalCode="10021" /> <phoneNumbers> <phoneNumber type="home" number="212 555-1234"/> <phoneNumber type="fax" number="646 555-4567"/> </phoneNumbers> </person>

Replies are listed 'Best First'.
Re: OT: xml format question (offtopic!)
by LanX (Saint) on May 21, 2013 at 14:08 UTC

      LanX ,

        (Not a Perl question, please mark OT!)

      Interesting, that I recently added 'OT' to the beginning of a title on a 'Coldfusion/XML' to Perl question, and was immediately given an error msg that I violated "PM" rules. I deleted the 'OT' from the title and the thread was accepted.

      Do we have to add '(offtopic)' to the end of the title?

      Thank you...Ed

      "Well done is better than well said." - Benjamin Franklin

        Adding "OT" does not make an off-topic question better. If it has no relevance to Perl, you need to give more justification why it is posted on a site named Perlmonks.

        Coldfusion is far outside of that, unless you need to talk to it from Perl, for example.

        flexvault

        > and was immediately given an error msg that I violated "PM" rules

        really? No idea. I don't belong to any of teh special PM groups, so I can't answer this.

        Maybe asking at PMD helps.

        > Do we have to add '(offtopic)' to the end of the title?

        I added to the end now to avoid confusion.

        AFAIK it's tradition to prepend "OT".

        Cheers Rolf

        ( addicted to the Perl Programming Language)

Re: OT: xml format question
by Corion (Patriarch) on May 21, 2013 at 13:39 UTC

    "Practical difference" would depend on what you want to do with the XML.

    For example, if you want to extract information from the XML, the XPath queries would be different for the two XML formats.

      is that the primary reason you would choose one over the other?

        If I were to choose, I wouldn't choose XML at all.

        JSON seems much nicer and less verbose to me, and it has far less choices like encoding, entities, comments and references to external things.

        It lacks schema definitions and tooling though.

Re: OT: xml format question
by tobyink (Canon) on May 21, 2013 at 15:37 UTC

    Personally I wouldn't use either - I'd use xCard or vCard RDF.

    Why design yet another contacts format, when you can re-use an existing standard and have at least a slight chance of interoperability with other tools?

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re: OT: xml format question
by rovf (Priest) on May 21, 2013 at 15:01 UTC