您当前的位置: 首页 >  unity

程序员正茂

暂无认证

  • 5浏览

    0关注

    283博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

unity读取解析xml

程序员正茂 发布时间:2019-12-20 12:36:51 ,浏览量:5

xml格式如下:


       

解析XML

    //解析xml
    void parseXml()
    {
        //也可以前面加上@,区别就是有@的话,双引号里面的内容不转义,比如" \" "
        string filePath = Application.streamingAssetsPath + @"/config.xml";
        if (!File.Exists(filePath))
        {
            Debug.LogError("配置文件不存在");
            return;
        }

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(filePath);
        XmlNodeList node = xmlDoc.SelectSingleNode("item").ChildNodes;
        //遍历节点
        foreach (XmlElement ele in node)
        {
            if (ele.Name == "connect")
            {
                remoteServer = ele.Attributes["server"].Value;
                Debug.Log(remoteServer);
            }
        }
    }

 

关注
打赏
1660743125
查看更多评论
立即登录/注册

微信扫码登录

0.0368s