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 7417657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:44:26+00:00 2026-05-29T07:44:26+00:00

I’ve had a thorough look at the tinyxml (C++) tutorial but still can’t really

  • 0

I’ve had a thorough look at the tinyxml (C++) tutorial but still can’t really understand how I apply the examples to what I’m trying to do. What I’m trying to do in short is use an xml to generate a series of room objects in a game. Is someone able to give me a short example with the following xml and Room object, please? Xml is:

<room>
    <name>Prison room</name>
    <connections>
    <connection>Guard room</connection>
    </connections>
  <items>
    <item>
      <name>Short sword</name>
      <attack>2</attack>
       <armor>0</armor>
    </item>
  </items>
  <monsters></monsters>
</room>

Room object has the following fields:

std::vector<Item> itemsInRoom;
std::vector<Room> connectingRooms;
std::vector<Monster> monstersInroom;
std::string roomName;

Thanks in advance!

Edit: Removed the edit as that particular problem was solved.

  • 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-05-29T07:44:27+00:00Added an answer on May 29, 2026 at 7:44 am

    The first thing to do would be to learn more about XML and about representing/structuring/abstracting data. For example, it is usually unwise to encode e.g. the item “short sword” inside the room as you do. Rather you would want to provide a definition of that item (or a template of it) somewhere else and only have a reference to that, possibly with some extra parameters inside the room node. You will probably also want to learn to use attributes (all data is not the same, some data should be attributes).

    Once you have groked that, the actual TinyXML stuff is easy. TinyXML is about as simple as it can get:

    1. Agree on some semantics. Write them down, remember them, follow them when you create the XML files.
    2. Create a TiXmlDocument, give it the name of your data file
    3. Call LoadFile on your document object
    4. Call FirstChildElement, giving you the root node (note that if you have more than one room in the XML you need to have a separate root node!)
    5. Iterate over the cildren using FirstChildElement and NextSiblingElement.
    6. Now you have to remember the structure of your XML file (or the semantics of its elements). TinyXML cannot magically figure that out for you.
    7. Use FirstChildElement and NextSiblingElement in the same manner as for the room nodes for “anything inside” each room (whatever you decided that may be) to figure out what each room looks like and what’s in them. You must know what this data means, TinyXML cannot know this kind of thing, it merely provides you with structured data.
    8. Resolve references and set up the corresponding data structures (e.g. when you have something like <door to="guard_room" x="5" y="3" status="locked" /> create the necessary links so your game reacts appropriately.

    (and don’t forget to check for errors)

    The tutorials at the TinyXML site are also very easy to understand (last I looked some 2-3 years ago, you could basically copy-paste them). If these really pose a considerable problem, I’d reconsider the idea of writing a RPG for the time being. I’m not saying forever, but at least until you have enough experience to follow these.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns 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.