SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: XML bad format?

  1. #1
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML bad format?

    How about this format?
    Code XML:
    <name>cData1
    <category>cData2
    <name>cData3</name>
    </category>
    </name>
    I've been asked to include this as a test case in an assignment. What do you think?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,191
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    Hi gavincangan, welcome to the forums

    I suppose a lot depends on what Data1, Data2, and Data3 are.

    But I don't like the way it's nested at all and I think reusing the "name" tag is an unwise choice.

  3. #3
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do understand that the formatting looks bad. But I've been asked to take this test case into consideration! So I'll have to handle it anyway
    I was just wondering if there was any grammar in XML which prohibited using same tag name in different levels

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,191
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    I have seen a lot of XML that uses the same tag names. But they have different namespaces so they aren't really the same name.
    eg.
    <a:name>whatever</a:name>
    <b:name>whosit</b:name>
    etc.

    The trouble with the format of your example is that XML is used for transporting data. If someone parses the file for "name" they should be able to get what they want as specifically and as easily as possible. Not knowing which level "name" is at is neither.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •