INTRODUCTION TO XML
- ep3g19
- May 23, 2021
- 1 min read
"Introduction to XML for Games" - Lecture with Jame 7th May.
PART ONE:
What is XML?
"XML is a language form for scripting things in a way that can easily be converted to code and is also easy to read and write".
Traditionally used when writing websites
Good for making data structures for code
JAMES' EXAMPLE
Character for our game:

Turning this into XMl:
Create tags e.g. <character>
TAGS
<example></example>
Both start and end tag must be spelled the same way.
End tags are indicated by '/' in front of the tag name.
In between tags is where you can put information e.g. game specific values.
E.g. <value_example>54</value_example>
In XML:
<character>
<name></name>
<class></class>
<level></level>
<xp></xp>
<hp></hp>
</character>
We fill in these values using our original 'on-paper' design.
<character>
<name></Cynthia Rosethorn</name>
<class>Pilot</class>
<level>4</level>
<xp>4500</xp>
<hp>15</hp>
</character>
Assigning data types for each value:

We then must turn these into variables in order to convert this into C#.

OUR TASK
Design a magical item
Create and fill-in an XML document
Create a receiving class for your item's structure
MY MAGICAL ITEM
WHAT DID I DO?
I began by establishing a magical item, in this case it's Doughnut. I labelled the type of item as 'Health' and the number of points it would essentially give players is 3, as well as 1000 XP. I have displayed this in a table to begin with:
'On-paper design'

Converting this into XML

C#

コメント