9 - Reading the XML

Now that we have explored how we can write our data to disk, we'll take a look at how to read the data that we just wrote in 8 - Writing to XML. The logic for this is quite easy to understand through how we will open the document and then subsequently get the the child once again and the score located within it.

In order to finish of the lesson we will use a concatenation node of a string that prefixes the score attribute and prints to the screen through a display message on the viewport.

How To Read XML

Follow the steps below to read XML data within Flow Graph:

  1. Create a XML:OpenDocument node and passing the Success port of the XML:SaveDocument from the prior lesson into the Execute input port.
  2. Inside of the XML:OpenDocument, look for the name of the document we saved in the previous chapter and in this case add .xml (example: Collin.xml)
  3. Create a XML:GetChild node and then we will look for the child Score which we declared in the previous chapter and connect the Success port from the XML:OpenDocument node.
  4. Create a XML:GetValue node and connect the Success port of the XML:GetChild node into the Execute trigger of the XML:GetValue.
  5. Take the value and pass this on to a String:Concat node in order to add "DISK READ: " to our printed text and outputting to a Debug DisplayMessage node in order to differentiate the read text from the printed one.
  6. Jumping into game (Ctrl+G) and killing 5 AI should show text similar to as shown in the image below.

Step 1

Step 2

Step 3

Step 4

Step 5-1

Step 5-2

Final Result

Conclusion

Although this tutorial has concluded, feel free to venture out on your own development path based on what we've covered in the previous chapters. For information on the topics covered in this tutorial and more, please refer to the CRYENGINE V Manual.