How do I split imported XML points into separate groups?

nicadolly

New Member
I'm trying to import an XML file that contains a list of points for a drawLine function, it's the typical drawLine function, give it your X1, Y1, X2, Y2 coordinates and it will draw the line. What I have in my XML file is as follows:\[code\]<LINES> <LINE> <ID>J3U93</ID> <POINT X="454.5" Y="93.5"></POINT> <POINT X="454.5" Y="371"></POINT> <POINT X="433.5" Y="351"></POINT> <POINT X="433.5" Y="329.5"></POINT> </LINE> <LINE> <ID>U231U93</ID> <POINT X="23.5" Y="526"></POINT> <POINT X="417" Y="341.875"></POINT> <POINT X="380" Y="341.875"></POINT> <POINT X="188.5" Y="526"></POINT> <POINT X="23.5" Y="526"></POINT> </LINE> . .</LINES>\[/code\]Each line has an ID to distinguish it in the file, my lines will join up up to essentially form Z shape patterns i.e. varied amount of turns depending on the amount of points are within the LINE tag.What I need would like to know, or if you can point me in the right direction is how do I separate one set of lines within the ID tags from another set of lines in another ID tag?So far I tried:\[code\]List<Point> Points;XDocument lineDataXml = XDocument.Load(filename);Points = ( from point in lineDataXml.Descendants("LINE") select new Point { X = Double.Parse(point.Attribute("X").Value), Y = Double.Parse(point.Attribute("Y").Value) }).ToList(); foreach(Point a in Points) { Console.WriteLine(a); }\[/code\]but this returns a list of all points in the XML without knowing what points belong to which ID.Your help would be greatly appreciatedPeter.
 
Back
Top