Tinyxml C++ Grabbing Id

Started by
1 comment, last by Elit3d 7 years, 8 months ago

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>
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/

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!

This topic is closed to new replies.

Advertisement