Need help with XML Parsing. (C sharp)

I’m trying to get my program to read an XML file from my other program, but it fails to load text info from the XML file.
The script can detect the XML file (and its contents) just fine, but I need help getting the text from the XML file to my program.

Here’s the XML file for reference:

<GameInformation>
	<ProgramInfo>
  		<nameInfo> Nameing = "Program Title"</nameInfo>
  		<coderInfo> Coder = "By me"</coderInfo>
 		<versionInfo> Version = "1"</versionInfo>
  		<descriptionInfo> Description = "This is an XML file I am trying to get my program to read.</descriptionInfo>
	</ProgramInfo>
</GameInformation>

And here’s my script also for reference:

using UnityEngine;
using UnityEngine.UI;
using System.Xml.Serialization;
using System.IO;
using System.Text;
using System;
using System.Xml;
using System.Collections;
using System.Collections.Generic;

[System.Serializable]
 public class GameInfo {
 
	[XmlIgnore]/*[System.NonSerialized]*/ 
	//public GameObject muzzleflashObject;
 	
	[XmlAttribute("nameInfo")] public string Nameing = "";
	[XmlAttribute("coderInfo")] public string Coder = "";
	[XmlAttribute("descriptionInfo")] public string Description = "";
	[XmlAttribute("versionInfo")] public int Version = 1;
 
 }

 [System.Serializable]
 [XmlRoot("GameInformation")]
 public class InfoDirectory {
     [XmlElement("ProgramInfo")]
     public GameInfo[] GameInformation;
     
 }

public class XMLTest : MonoBehaviour {

	public string XmlPrint;
	public Text GameTitleText;
	public GameObject TitleTempStorage;
	public Component Curr;


	public Dictionary<string,GameInfo> InfoDictionary;	

	void Start(){
		ReadGameInfo();
		Debug.Log ("Did it work?");
	}
 
	void ReadGameInfo() {
		System.IO.FileStream fileStream;
		XmlReader reader;
           InfoDictionary = new Dictionary<string,GameInfo>();
         
            string path = "C:/GameInfo.xml";
	GameTitleText = GameObject.Find("GameTitle").GetComponent<Text>();
	TitleTempStorage = GameObject.Find("TitleTempStorage");
	Curr = TitleTempStorage.GetComponent<CurrentGameTitle>();
         
            var xmlSerializer = new XmlSerializer(typeof(InfoDirectory));
		var stream = File.Open("C:/GameInfo.xml", FileMode.Open, FileAccess.Read);
            var deserializedInfo = xmlSerializer.Deserialize(stream) as InfoDirectory;
		reader = new XmlTextReader(stream);
				         

            stream.Close();
		
		Debug.Log(deserializedInfo.GameInformation.Length);    

            for(int i = 0; i < deserializedInfo.GameInformation.Length; i++) {
                GameInfo ProgramInfo = deserializedInfo.GameInformation*;*
  •  	XmlPrint = "This is " + (ProgramInfo.Nameing) + ", made by " + (ProgramInfo.Coder);*
    
  •  	GameTitleText.text = (ProgramInfo.Coder);*
    
  •  	Debug.Log ("Well, did it? " + ProgramInfo.Description);*
    
  •  	//(ProgramInfo.name, ProgramInfo); //-Not in use.*
    

}
}

}
If you know what’s wrong, please let me know. None of the answers on here has helped me so far and I want to get this part of my program over with (I’ve been trying to figure out how to display text from an XML file for nearly 4+ days already.) and continue with the rest of my program. Thanks!

Your XML data makes no sense and it can’t be parsed into the class you have defined. An XML file doesn’t have key-value pairs like JSON. You have elements which can have sub elements or just a data value. However your elements contain a string which in turn seems to represent some sort of key-value pair

For example you have an element “nameInfo” but the content of that element is this: Nameing = "Program Title". You probably want to store just Program Title in that element.

Next thing is you marked your 4 fields in your “GameInfo” class as “XmlAttribute” but you actually defined elements. So the XML which would fit to your class would look like this:

<GameInformation>
    <ProgramInfo nameInfo="Program Title" coderInfo="By me" versionInfo="1" descriptionInfo="This is an XML file I am trying to get my program to read" />
</GameInformation>

If you want to use elements instead you have to define your class like this:

[System.Serializable]
public class GameInfo
{
     [XmlElement("nameInfo")] public string Nameing = "";
     [XmlElement("coderInfo")] public string Coder = "";
     [XmlElement("descriptionInfo")] public string Description = "";
     [XmlElement("versionInfo")] public int Version = 1;
}

The XML for this class would look like this:

<GameInformation>
    <ProgramInfo>
        <nameInfo>Program Title</nameInfo>
        <coderInfo>By me</coderInfo>
        <versionInfo>1</versionInfo>
        <descriptionInfo>This is an XML file I am trying to get my program to read.</descriptionInfo>
    </ProgramInfo>
</GameInformation>

Still looking for an answer…