Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a 3D object and their data points. Data consists of 1000 points.
The following are for the data points.
C#
public static List<myline> OpenProject(string _file)
        {
            List<myline> Lines = new List<myline>();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(_file);
            XmlNodeList coordinates = doc.SelectNodes("/Siene/MyLine/Coordinates");
            foreach (XmlNode coordinat in coordinates)
            {
                int x1 = Int32.Parse(coordinat["Start"].Attributes["X"].Value);
                int y1 = Int32.Parse(coordinat["Start"].Attributes["Y"].Value);
                int z1 = Int32.Parse(coordinat["Start"].Attributes["Z"].Value);
                MyLine czg = new MyLine(x1, y1, z1);
                lines.Add(czg);
            }
            return lines;
        }

Instead of loading from an external file (doc.LoadXml(_file), the XML file must be in solution explorer and all data points must be able to read from there.
The line "doc.LoadXml(_file);" must e removed. That is, data reading from XML file must not need "OpenFileDialog" and must be inside the code.

Could you say me how it can be done.
Regards,
Mark
Posted
Updated 15-Aug-11 15:05pm
v4
Comments
Wendelius 15-Aug-11 17:42pm    
Added pre tags

I recommend using LINQ to parse your XML, it's much neater.

StreamResourceInfo sri = System.Windows.Application.GetResourceStream(new System.Uri("pack://application:,,,/MediaData/germanDiaIndex.xml"));

XmlTextReader xmlReader = new XmlTextReader(sri.Stream);


is how my app reads an XML file from resources. As you can see, sri.Stream gives you a stream to use to read the data, if you move it to LINQ, I'm sure you can use a stream to do that.
 
Share this answer
 
One solution is to include the XML file in your project resources. For an example of how to do this for a Jet DB, see this link[^], which you can modify to include any sort of file that you want.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900