• Advertisement
Sign in to follow this  

Tinyxml C++ Grabbing Id

This topic is 625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I am using tinyxml with c++ and its my first time really parsing with it and xml. Is it possible to, when the text element is pressed, grab the goto attribute and set the dialog id to that attribute. Can't seem to figure out a way to grab the id when the text element is clicked.

<dialogtree>
  <dialog id='0'>
	<name>Boss</name>
    <message name="Boss" text="Testing the dialog system!"></message>
	<responses>
		<response condition="True" goto='1'>
		  response text
		</response>
		<response condition="False" goto='2'>
		  response text
		</response>
		<response condition="False" goto='2'>
		  response text
		</response>
	</responses>
  </dialog>
  <dialog id='1'>
	<name>Player</name>
    <message name="Boss" text="Next message"></message>
	<responses>
		<response condition="True" goto='3'>
		  response text
		</response>
		<response condition="False" goto='4'>
		  response text
		</response>
		<response condition="False" goto='4'>
		  response text
		</response>
	</responses>
  </dialog>
</dialogtree>
Edited by Elit3d

Share this post


Link to post
Share on other sites
Advertisement

I am not sure how you are processing this xml in your code, but generally you would load the xml data into an internal data structure that is easier to work with.

 

A map data structure could be used where the key is the id and the value is instance of a Dialog class.

 

I think the key idea is that your xml would get turned into an in memory data structure. For instance you could have a vector of response objects in the Dialog class.

 

http://www.cprogramming.com/tutorial/stl/stlmap.html

 

http://www.cplusplus.com/reference/map/map/

Edited by shadowisadog

Share this post


Link to post
Share on other sites

I am not sure how you are processing this xml in your code, but generally you would load the xml data into an internal data structure that is easier to work with.

 

A map data structure could be used where the key is the id and the value is instance of a Dialog class.

 

I think the key idea is that your xml would get turned into an in memory data structure. For instance you could have a vector of response objects in the Dialog class.

 

http://www.cprogramming.com/tutorial/stl/stlmap.html

 

http://www.cplusplus.com/reference/map/map/

 

Oh so by using the map structure, it will allow me to print out the text along with the next id to make a simple id handler in a way? Thanks I will try this and maybe will paste my code here if anyone else stumbles on this post!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement