private void LoadXMLButton_Click(object sender, EventArgs e) { listViewXMLLoad.Items.Clear(); String XMLAddress = TextboxXMLLoader.Text; XmlDocument XMLdoc = new XmlDocument(); String lane = "", frame_start = "", frame_end = "", speed = ""; try { XMLdoc.Load(XMLAddress); XmlNodeList nodeList = XMLdoc.DocumentElement.SelectNodes("/GroundTruthRoot/gtruth/vehicle/radar"); foreach (XmlNode node in nodeList) { speed = node.Attributes["speed"]?.InnerText; frame_end = node.Attributes["frame_end"]?.InnerText; frame_start = node.Attributes["frame_start"]?.InnerText; lane = node.ParentNode.Attributes["lane"]?.InnerText; try { listViewXMLLoad.Invoke((MethodInvoker) delegate { var ListViewitem = new ListViewItem(new[] { lane, frame_start, frame_end, speed }); listViewXMLLoad.Items.Add(ListViewitem); }); } catch (Exception ListViewUpdateErr) { MessageBox.Show("Error in updating list:" + ListViewUpdateErr.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception xmlloadexception) { MessageBox.Show("Error in reading file" + xmlloadexception.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadCalculatedXMLButton_Click(object sender, EventArgs e) { listViewCalculatedXML.Items.Clear(); String XMLAddress = textBoxCalculatedXMLLoader.Text; XmlDocument XMLdoc = new XmlDocument(); String lane = "", vehicleID = "", frame_end = "", speed = ""; try { XMLdoc.Load(XMLAddress); XmlNodeList nodeList = XMLdoc.DocumentElement.SelectNodes("/VideoSpeedMeasurement/vehicle"); foreach (XmlNode node in nodeList) { speed = node.Attributes["speed"]?.InnerText; frame_end = node.Attributes["frameEnd"]?.InnerText; vehicleID = node.Attributes["vehicleID"]?.InnerText; lane = node.Attributes["region"]?.InnerText; try { listViewCalculatedXML.Invoke((MethodInvoker) delegate { var ListViewitem = new ListViewItem(new[] { vehicleID, lane, frame_end, speed }); listViewCalculatedXML.Items.Add(ListViewitem); }); } catch (Exception ListViewUpdateErr) { MessageBox.Show("Error in updating the list view:" + ListViewUpdateErr.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception xmlloadexception) { MessageBox.Show("Error in reading file" + xmlloadexception.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }