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

  • Home
  • SEARCH
  • 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 8204099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:47:22+00:00 2026-06-07T07:47:22+00:00

How can I make something like this work with range based loops for both

  • 0

How can I make something like this work with range based loops for both Elements and Attributes?

#include <list>
#include "XMLAttribute.h"

namespace XML
{
    class Element
    {
        private:
            typedef std::list<Attribute> attribute_container;
            typedef std::list<Element> element_container;

        public:
            XMLElement();

            bool has_attributes() const;
            bool has_elements() const;
            bool has_data() const;

            const std::string &name() const;
            const std::string &data() const;

        private:
            std::string _name;
            std::string _data;

            attribute_container _attributes;
            element_container _elements;
    };
}

I would like to be able to use something like:

for (XML::Element &el : element) { .. }
for (XML::Attribute &at : element) { .. }

And block something like for (auto &some_name : element) { .. } //XML::Element or XML::Attribute?.

Is it a good idea to implement it like this or should I change my design?

  • 1 1 Answer
  • 0 Views
  • 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-06-07T07:47:24+00:00Added an answer on June 7, 2026 at 7:47 am

    The correct answer is to give Element nodes functions that return ranges of child attributes and elements. Thus, you can do this:

    for(auto &element : element.child_elements()) {...}
    for(auto &attribute : element.attributes()) {...}
    

    Your child_elements function would return some kind of type that stores two iterators, like a boost::iterator_range. attributes would likewise return a range for attribute elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I make something like this below work? <?PHP $_SESSION['signup_errors']['test1']; $_SESSION['signup_errors']['test2']; $_SESSION['signup_errors']['test3']; $_SESSION['signup_errors']['test4'];
I wasnt to make something like this site where I can scroll up and
Is there a way to make something like this work? program Project1; {$APPTYPE CONSOLE}
How can i make something similar like GMail has http://o7.no/H72gPf When application starting, gmail
and I am tearing my hair out!! Even something simple like this work: procedure
===EDIT=== Is there a reason something like this doesn't work i feel like it
Can we modify a Boolean value in class function in java, something like this
According to http://lipas.uwasa.fi/~ts/info/proctips.html#orrules , you can make basic or rules in .procmailrc with something
I can make batch or vbs file on windows and run. this can automate
I thought something like this <ajaxToolkit:CalendarExtender ID=TextBox1_CalendarExtender runat=server TargetControlID=txtDatumPoaganje Format=MM/dd/yyyy StartDate=<%=DateTime.Now%>> But it doesnt

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.