Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 276909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:59:29+00:00 2026-05-12T00:59:29+00:00

Let’s say you want to allow some particular XML element to occur 0+ times.

  • 0

Let’s say you want to allow some particular XML element to occur 0+ times. For example, the <record> element can occur multiple times:

<repository>
  <record>Record 1</record>
  <record>Record 2</record>
  <record>Record 3</record>
</repository>

Are there any compelling reasons to include a parent element as a container for these? For example, the following uses the <recordSet> element to contain the <record> elements:

<repository>
  <recordSet>
    <record>Record 1</record>
    <record>Record 2</record>
    <record>Record 3</record>
  </recordSet>
</repository>

I tried to find any related questions before posing this, so my apologies if it has been asked already. Thanks in advance for any and all input!


Edit – July 22, 2009:

Thanks to everyone for the excellent feedback! (I would comment / vote people up, but I don’t have enough reputation points quite yet.) I’ll probably go ahead with this route, and I also wanted to thank @16bytes for their advice, including to simply name the parent by using the plural of the reoccurring child elements.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:59:30+00:00Added an answer on May 12, 2026 at 12:59 am

    Having a parent element makes it simpler to identify sections of the XML and makes it simpler for handlers to map the child elements to a collection.
    If you have a system that forbids the use of attributes (some do, it’s annoying), you also need to use wrapper elements to distinguish properties (such as ids) that belong to particular children.

    Other than that it is valid to omit the parent element and can make the file markedly less verbose.

    In your first example, a user element could be mingled in with the records, this is valid but it might be hard to spot:

    <repository>
      <record>Record 1</record>
      <record>Record 2</record>
      <user>Bill</user>
      <record>Record 3</record>
    </repository>
    

    Whereas with a surrounding element you can separate the collection, and have multiple instances of that collection:

    <repositories>
      <users>
        <user>Bill</user>
      </users>
      <repository>
        <id>id1</id>
        <recordSet>
          <id>recordSet1</id>
          <record>Record 1</record>
          <record>Record 2</record>
          <record>Record 3</record>
        </recordSet>
        <recordSet>
          <id>recordSet2</id>
          <record>Record 1</record>
          <record>Record 2</record>
          <record>Record 3</record>
        </recordSet>
      </repository>
      <repository>
        <id>id2</id>
        <recordSet>
          <record>Record 1</record>
          <record>Record 2</record>
          <record>Record 3</record>
        </recordSet>
      </repository>
    </repositories>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let's say I have some 6 random numbers and I want to calculate some
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let me try to explain by example. Say website is hosted at example.com (NOT
Let's say I have a table with a Color column. Color can have various
Let's say I have thousands of users and I want to make the passwords
Let's say that each Product has a category. I want to ask the Users
Let's say I have a file foo.py, and within the file I want to
Let's say if the user is able to select some directories to search. And
Let's say I have some text as follows: do this, do that, then this,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.