Unity uses Mono. Xml instead of System. Xml for testing. mono. xmlsystem. xml

Source: Internet
Author: User

Unity uses Mono. Xml instead of System. Xml for testing. mono. xmlsystem. xml

Test Environment

Operating System: Windows8.1

Development Tool: Unity5.5.2

1. Create a new test project and observe the correctness of the parsing files referenced by System. Xml and Mono. Xml, and the size of the packaged APK.

2. Mono. Xml use case

using UnityEngine;using Mono.Xml;using System.Security;public class MonoXmlTest : MonoBehaviour {        void Start () {        SecurityParser parser = new SecurityParser();        string xmlPath = "test";        parser.LoadXml(Resources.Load(xmlPath).ToString());        SecurityElement element = parser.ToXml();                foreach (SecurityElement node in element.Children)        {                     if (node.Tag == "table")            {                string wave = node.Attribute("wave");                string level = node.Attribute("level");                string name = node.Attribute("name");                Debug.Log("wave:" + wave + " level:" + level + " name:" + name);            }        }    }    }

 

 

3. System. xml use case

using UnityEngine;using System.Xml;public class SystemXmlTest : MonoBehaviour {    // Use this for initialization    void Start () {                 XmlDocument xml = new XmlDocument();            XmlReaderSettings set = new XmlReaderSettings();                        xml.LoadXml(Resources.Load("test").ToString());                        XmlNodeList nodes = xml.SelectSingleNode("ROOT").ChildNodes;                        foreach (XmlElement node in nodes)            {                string wave = node.GetAttribute("wave");                string level = node.GetAttribute("level");                string name = node.GetAttribute("name");                Debug.Log("wave:" + wave + " level:" + level + " name:" + name);        }    }    }

4. Conclusion: Mono. Xml is used to replace System. Xml. After the APK installation package is compiled, the size is reduced by about KB. We recommend that you use Mono. Xml.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.