Serial Port XML Data parsing errors

Posted 09 June 2011 - 04:34 PM

Hello

I am trying to parse incoming data from a serial port that appears to be XML format but a few problems arise when going from a simulated setup to the real deal.

I first made a this program at home using a serial port emulator and com port connector program that reads from a text file and then sends it through the com port, I then read it from the com port it is connected to it. My program is able to parse the incoming XML perfectly fine, I'm using an XML Literals syntax.

The problem I run into is when I setup my program with the device and try and parse the data that is coming out of it. The data I receive sometimes has a few lines of garble before it starts seeing my expected XML. Of course these few lines of garbled text throws me an exception, but even when it appears I'm getting a good clean start of my XML data my program still throws exceptions such as "unexpected end of line 1 line number (different lines)" or "multiple root elements line 1"

Am I going about this the right way? using XML Literals to process my XML string properly or should I use something else that will allow for not well formed XML? or am I just missing something.

My device outputs data every 500ms and I can poll my device for stored data. An example of what I am receiving sometimes and what I am expecting is below. "The first few lines of text sometimes appear and sometimes don't"

Re: Serial Port XML Data parsing errors

Posted 09 June 2011 - 05:55 PM

Hey Hawk

You really think Regex is the way to go? Gezzz that kills man, it had taken me weeks just to get it to work properly using the XML Literals syntax which was great and all because it looks so clean and neat. When I look at Regex syntax i just cringe lol it's just ugly looking to me lolol. Anyway enough of me wining, could you give me a small example of how to start or some links to sites that could point point me in a beginners direction. lol