parsing XML files with the Mono plugin in Unity

Source: Internet
Author: User

1. Unzip the package and drag the folder to the script folder

Mono is an open source developed by a third-party foundation, and programs developed on a mono basis can be run under individual systems. The development language is C #.

With the plug-in resolution is more efficient, the platform stable operation. Easy to use.

Mono compression package can be found in the Unity installation path

2. New Script Xmltest

Using Unityengine;

Using System.Collections;

Using Mono.xml;

Using System.Security;

public class Xmltest:monobehaviour {

Test whether XML is available

Use this for initialization

void Start () {

Loading an external XML document

String strxml = Resources.load ("Enemy"). ToString ();

Parse the XML, generate the Securityparser object, and parse the string into XML format

Securityparser parse = new Securityparser ();

Pass in the string to parse

Parse. LOADXML (strxml);

Gets the root node of the load XML

SecurityElement SE = parse. TOXML ();

Traverse se Sub-node, SE stands for root, child node represents table

foreach (securityelement element in SE. Children)

{

Determine if the node is a table first

if (element. Tag.equals ("table"))

{

Output All wave property values

Debug.Log (element. Attribute ("Wave"). ToString ());

Debug.Log (element. Attribute ("level"). ToString ());

}

}

}

Update is called once per frame

void Update () {

}

}

3. Create a new manager empty object in scene, hang the script on it, and run it.

Look at the console output, and if the output is the value of the variable in the XML file, the parse succeeds.

parsing XML files with the Mono plugin in Unity

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.