Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

Recommended Posts

I want get list of Vecror3 points from file. File have been recorded with Gatherer.

Share this post


Link to post
Share on other sites

Found old code. Have fixed some errors. Seems working now.

 public List<Vector3> GetPathFromXml(string path)
    {
        List<Vector3> xpath = new List<Vector3>();

        try
        {
            FileStream fs = new FileStream(path, FileMode.Open);
            StreamReader stream = new StreamReader(fs, Encoding.UTF8);
            string content = stream.ReadToEnd();    
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(content);
            var result = doc.GetElementsByTagName("Vectors3");
            var item = result.Item(0);

            foreach (XmlNode n in item.ChildNodes)
            {   
                var X = n.Attributes[0].Value;
                var Y = n.Attributes[1].Value;
                var Z = n.Attributes[2].Value;
                string type = n.Attributes.Count == 3 ? "None" : n.Attributes[3].Value;
                Vector3 v3 = new Vector3(float.Parse(X), float.Parse(Y), float.Parse(Z), type);
                xpath.Add(v3);
            }
          
            Logging.WriteError(" Xml file parsed !" + path);

        }
        catch (Exception e)
        {
            Logging.WriteError(e.ToString());
        }
        if (xpath.Count == 0) Logging.WriteError("No points in path");

        return xpath;
    }

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...