Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Hierarchical Data in a Web Application

$
0
0
I am creating an HTML5 game. Part of the content of the game is based on some hierarchical data. I need to take this data and load it into a tree data structure. I have my tree data structure working but I need to figure out exactly how to store the data. After much frustrating trial and error I realized that for all intents and purposes it's not possible to pull data into Javascript. So I couldn't have an XML file sitting in the same directory as the html and javascript files and load it and parse it. I found it utterly amazing that there was no workaround for this other than using node.js or something which I don't currently want to do. So given that that is impossible, which again is amazing since an HTML file can load in javascript files and images and other various sources, how would I store and process my hierarchical data? For the purposes of the question, assume the hierarchical data is basically of a form that would be conducive to the XML format. Currently my solution, which is extremely ugly and cumbersome is to handcode the data into javascript like this: var text = "<note>"+ "<to>Tove</to>"+ " <from>Jani</from>"+ "<heading>Reminder</heading>"+ "<body>Don't forget me this weekend!</body>"+ "</note>";

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>