ResourcesXMLReader.cs 861 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Xml;
  5. public class ResourcesXMLReader :MonoBehaviour {
  6. static ResourcesXMLReader instance;
  7. public static ResourcesXMLReader Instance
  8. {
  9. get
  10. {
  11. return instance;
  12. }
  13. set
  14. {
  15. instance = value;
  16. }
  17. }
  18. private void Awake()
  19. {
  20. instance = this;
  21. // ReadData();
  22. }
  23. public XmlNodeList ReadData(string XMLName, string XMLSearchingNode)
  24. {
  25. XmlDocument xml = new XmlDocument();
  26. TextAsset textAsset = (TextAsset)Resources.Load(XMLName);
  27. xml.LoadXml(textAsset.text); // suppose that myXmlString contains "<Names>...</Names>"
  28. XmlNodeList xmList = xml.SelectNodes(XMLSearchingNode/*"/Tweets/Tweet"*/);
  29. return xmList;
  30. }
  31. }