Data generation XML Import into Excel

Source: Internet
Author: User

void Generatexml (dictionary<string, prefabdict> dict)
{
String Xmlpath = Application.datapath + "/editor/characterseffectpoint/effectpointsinfo.xml";
if (file.exists (Xmlpath))
{
Debug.Log (Xmlpath);
File.delete (Xmlpath);
}

XmlDocument xmldoc = new XmlDocument ();
XmlDeclaration xmldecl;
Xmldecl = Xmldoc.createxmldeclaration ("1.0", "UTF-8", null);
XmlElement root = xmldoc.documentelement;
Xmldoc.insertbefore (xmldecl, Root);

XmlElement infoBase = xmldoc.createelement ("InfoBase"); Create root node, top-level node role name
Xmldoc.appendchild (infoBase);

foreach (var dic in Dict)
{
XmlElement characterinfo = xmldoc.createelement ("Effectpointsinfo");
Infobase.appendchild (Characterinfo);

XmlElement Characterkey = xmldoc.createelement ("Character");

XmlElement head_c_effectpoint = xmldoc.createelement ("Head_c_effectpoint");
XmlElement head_t_effectpoint = xmldoc.createelement ("Head_t_effectpoint");
XmlElement hand_l_effectpoint = xmldoc.createelement ("Hand_l_effectpoint");
XmlElement hand_r_effectpoint = xmldoc.createelement ("Hand_r_effectpoint");

XmlElement foot_l_effectpoint = xmldoc.createelement ("Foot_l_effectpoint");
XmlElement foot_r_effectpoint = xmldoc.createelement ("Foot_r_effectpoint");
XmlElement chest_effectpoint = xmldoc.createelement ("Chest_effectpoint");
XmlElement bottom_effectpoint = xmldoc.createelement ("Bottom_effectpoint");

XmlElement weapon01_effectpoint = xmldoc.createelement ("Weapon01_effectpoint");
XmlElement normal_hurtpoint = xmldoc.createelement ("Normal_hurtpoint");
XmlElement special_hurtpoint = xmldoc.createelement ("Special_hurtpoint");
XmlElement footsteps_effectpoint = xmldoc.createelement ("Footsteps_effectpoint");

Characterkey.innertext = dic. Key.tostring ();

Head_c_effectpoint.innertext = dic. Value.Head_C_EffectPoint.ToString ();
Head_t_effectpoint.innertext = dic. Value.Head_T_EffectPoint.ToString ();
Hand_l_effectpoint.innertext = dic. Value.Hand_L_EffectPoint.ToString ();
Hand_r_effectpoint.innertext = dic. Value.Hand_R_EffectPoint.ToString ();

Foot_l_effectpoint.innertext = dic. Value.Foot_L_EffectPoint.ToString ();
Foot_r_effectpoint.innertext = dic. Value.Foot_R_EffectPoint.ToString ();
Chest_effectpoint.innertext = dic. Value.Chest_EffectPoint.ToString ();
Bottom_effectpoint.innertext = dic. Value.Bottom_EffectPoint.ToString ();

Weapon01_effectpoint.innertext = dic. Value.Weapon01_EffectPoint.ToString ();
Normal_hurtpoint.innertext = dic. Value.Normal_HurtPoint.ToString ();
Special_hurtpoint.innertext = dic. Value.Special_HurtPoint.ToString ();
Footsteps_effectpoint.innertext = dic. Value.Footsteps_EffectPoint.ToString ();

Characterinfo.appendchild (Characterkey);
Characterinfo.appendchild (Head_c_effectpoint);
Characterinfo.appendchild (Head_t_effectpoint);
Characterinfo.appendchild (Hand_l_effectpoint);
Characterinfo.appendchild (Hand_r_effectpoint);

Characterinfo.appendchild (Foot_l_effectpoint);
Characterinfo.appendchild (Foot_r_effectpoint);
Characterinfo.appendchild (Chest_effectpoint);
Characterinfo.appendchild (Bottom_effectpoint);

Characterinfo.appendchild (Weapon01_effectpoint);
Characterinfo.appendchild (Normal_hurtpoint);
Characterinfo.appendchild (Special_hurtpoint);
Characterinfo.appendchild (Footsteps_effectpoint);

}

Xmldoc.save (Xmlpath); Create a Effectpointsinfo.xml file
Assetdatabase.refresh ();
This. Shownotification (New Guicontent ("Data generation:" + Xmlpath));
}

Data generation XML Import into Excel

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.