I'm having trouble with parsing an XML data from serial port.
Actually I need to parse it automatically after all data is received from serial port.
I can display all the data in a richtextbox control and all data is received perfectly but my problem is
it seems that serialdata.eof function seems like it's not firing.
any advice will be much appreciated!
here's some of my code:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'set serial port properties With COMPort .BaudRate = 19200 .Parity = Ports.Parity.None .DataBits = 8 .StopBits = Ports.StopBits.One .PortName = COM1 End With txtMonitor.BackColor = Color.Black txtMonitor.ForeColor = Color.White txtMonitor.Text = "" AddHandler COMPort.DataReceived, AddressOf Receiver End Sub Private Sub Receiver(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Dim Incoming As String Dim sp As SerialPort = CType(sender, SerialPort) counter = COMPort.BytesToRead Select Case e.EventType Case SerialData.Chars Incoming = sp.ReadLine() returnStr &= Incoming Me.Invoke(New MethodInvoker(AddressOf Display)) Case SerialData.Eof Me.Invoke(New MethodInvoker(AddressOf parseXML)) End Select End Sub Private Sub Display() txtMonitor.Text = returnStr End Sub Private Sub parseXML() Dim sr As New StringReader(returnStr) Dim doc As New XmlDocument Dim m_nodelist As XmlNodeList Dim m_node As XmlNode doc.Load(sr) '...and so on.... End Sub
what i need to know is how can i automatically parse the XML data from serial port after all data is received.