Guest User

readXml

a guest
Sep 7th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Xml;
  5.  
  6. public class readXml : MonoBehaviour {
  7.  
  8.  
  9.     public static string getLanguage(){
  10.         return PlayerPrefs.GetString ("language");
  11.     }
  12.  
  13.     public static void setLanguage(string s){
  14.         PlayerPrefs.SetString ("language", s);
  15.     }
  16.  
  17.     public static string getFieldLanguage(string s){
  18.         TextAsset txtA = Resources.Load ("language") as TextAsset;
  19.         XmlDocument doc = new XmlDocument();
  20.         XmlNode root;
  21.         XmlNodeList node;
  22.         doc.LoadXml (txtA.text);   
  23.         root = doc.DocumentElement;
  24.         node = root.SelectNodes (getLanguage());
  25.         return node[0].SelectSingleNode(s).InnerText;
  26.     }
  27.        
  28.     public static List<string> getLanguageList(){
  29.         TextAsset txtA = Resources.Load ("language") as TextAsset;
  30.         List<string> tmp = new List<string> ();
  31.         XmlDocument doc = new XmlDocument();
  32.         XmlNode root;
  33.         doc.LoadXml (@txtA.text);  
  34.         root = doc.DocumentElement;
  35.         foreach(XmlNode XN in root)
  36.             tmp.Add (XN.Name);
  37.         return tmp;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment