using System.Collections;
using System.Collections.Generic;
using System.Globalization;
public static void Main()
string input = @"<BODY><BAR><BRAN>ALSPEC</BRAN><SYST>Hunter 100mm Flush Glazed</SYST><CODE>AS308</CODE><DESC>Door Adaptor</DESC><DICL>NOTRE DAME GLOSS</DICL><DOCL>notre dame gloss p/coat</DOCL><LEN> 6500</LEN><STS>1</STS><POS> 0</POS><SVL> 0</SVL><IVL> 0</IVL><VROT> 0</VROT><VU1S> 0</VU1S><VU1D> 0</VU1D><VU2S> 0</VU2S><VU2D> 0</VU2D><LENR> 201.3</LENR><H> 26.5</H><MLT> 1</MLT><SCP> 0</SCP><BRS> 0</BRS><IFS> 0</IFS><BS1L> 0</BS1L><BS1R> 0</BS1R><BS2L> 0</BS2L><BS2R> 0</BS2R><ENTH> 0</ENTH><CUT><NUM> 1</NUM><TYPE></TYPE><ANGL> 45</ANGL><ANGR> 90</ANGR><AB1> 90</AB1><AB2> 90</AB2><IL> 2064</IL><OL> 2090.5</OL><BCOD>000000231/5/44</BCOD><CSNA></CSNA><CSNU></CSNU><TINA></TINA><DESC>Jamb - Right</DESC><STAT> 1</STAT><LBL>Job# 760 Item# 5</LBL><LBL>2090.5 mm</LBL><LBL>W2-D8/T15</LBL><LBL>Jamb - Right</LBL></CUT><CUT><NUM> 1</NUM><TYPE></TYPE><ANGL> 45</ANGL><ANGR> 90</ANGR><AB1> 90</AB1><AB2> 90</AB2><IL> 2064</IL><OL> 2090.5</OL><BCOD>000000231/2/45</BCOD><CSNA></CSNA><CSNU></CSNU><TINA></TINA><DESC>Jamb - Right</DESC><STAT> 1</STAT><LBL>Job# 760 Item# 2</LBL><LBL>2090.5 mm</LBL><LBL>D8/T23</LBL><LBL>Jamb - Right</LBL></CUT><CUT><NUM> 1</NUM><TYPE></TYPE><ANGL> 90</ANGL><ANGR> 45</ANGR><AB1> 90</AB1><AB2> 90</AB2><IL> 2064</IL><OL> 2090.5</OL><BCOD>000000231/1/43</BCOD><CSNA></CSNA><CSNU></CSNU><TINA></TINA><DESC>Jamb - Left</DESC><STAT> 1</STAT><LBL>Job# 760 Item# 1</LBL><LBL>2090.5 mm</LBL><LBL>D8/T24</LBL><LBL>Jamb - Left</LBL></CUT></BAR></BODY>";
var doc = XDocument.Parse(input);
var result = doc.Descendants("BAR")
Brand = e.Element("BRAN").Value,
System = e.Element("SYST").Value,
Code = e.Element("CODE").Value,
Description = e.Element("DESC").Value,
Length =e.Element("LEN").Value,
Status =e.Element("STS").Value,
Cuts = e.Descendants("CUT").Select(c=> new Cuts()
Cut_id = int.Parse(c.Element("NUM").Value),
AngleL = c.Element("ANGL").Value,
AngleR = c.Element("ANGR").Value,
LenInn = c.Element("IL").Value,
LenOut = c.Element("OL").Value,
Barcode = c.Element("BCOD").Value,
Description = c.Element("DESC").Value,
Status = c.Element("STAT").Value,
Label1 = c.Elements("LBL").First().Value,
Label2 = c.Elements("LBL").Skip(1).First().Value,
Label3 = c.Elements("LBL").Skip(2).First().Value,
Label4 = c.Elements("LBL").Skip(3).First().Value,
foreach (var res in result)
public int Bar_id { set; get; }
public string Brand { set; get; }
public string System { set; get; }
public string Code { set; get; }
public string Description { set; get; }
public string Length { set; get; }
public string Status { set; get; }
public string NumBars { set; get; }
public List<Cuts> Cuts { set; get; }
public int Cut_id { set; get; }
public int Bar_id { set; get; }
public string AngleL { set; get; }
public string AngleR { set; get; }
public string LenInn { set; get; }
public string LenOut { set; get; }
public string Barcode { set; get; }
public string Description { set; get; }
public string Status { set; get; }
public string Label1 { set; get; }
public string Label2 { set; get; }
public string Label3 { set; get; }
public string Label4 { set; get; }