I need to load the XML file that is in Assets (for example, lang.xml).
How to implement it?
1 answer
For example:
XmlDocument xmlDoc = new XmlDocument(); TextAsset textAsset = (TextAsset)Resources.Load(filePath, typeof(TextAsset)); xmlDoc.LoadXml(textAsset.text); Where filePath is the file path.
- Chet I'm not a lot stupid. The path to the file which lies in the folder with the game or in the Assets folder? - FAR747
- For example, you have the file:
Resources/Localization/ru-RU.xml- Ares - If you need to load with
dataPath, thenstring filePath= Application.dataPath + "/ru-RU.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filepath);string filePath= Application.dataPath + "/ru-RU.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filepath);- Ares - It works. Only here I use not XmlDocument, but Xdocument. - FAR747
- What is more convenient for you, then use it. LINQtoXML does not hurt. - Ares
|