Concept for analyze several XML messages, sometimes incomplete.
-
Hello,
I receive xml messages and need to analyze them. The messages may be incomplete.What is the best way to solve this?
MessageToAnalysis += IncomingData;
if start and end tag are present, start analysis. During the analysis, data can arrive again as a substring.Maybe loke this IncomingData.split("/ROOT>") ?
It could be that I am receiving </Ro
a little later </ot>Or I receive two messages at the same time?
Analyze first message, then second message<ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> </ROOT> <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> ///////////////// Part one <ROOT info="Partial receipt of messa Part two ges"> <START_REQ task="2" program="0178" /> </ROOT> /////////////////// Part one <ROOT info="Partial receipt of messa Part two ges"> <START_REQ task="3" program="0178" /> </ROOT><ROOT in
Thanks in advance.
Best regards Robert -
Hi,
Sounds like:
- cumulate the data in a buffer until you have a full message
- extract the message from the buffer
- process message
That way you can continue to fill the buffer while the processing is being done.
Rince and repeat -
Hi,
Sounds like:
- cumulate the data in a buffer until you have a full message
- extract the message from the buffer
- process message
That way you can continue to fill the buffer while the processing is being done.
Rince and repeat@SGaist said in Concept for analyze several XML messages, sometimes incomplete.:
- cumulate the data in a buffer until you have a full message
- extract the message from the buffer
OK, Do you have a good sample?
-
@SGaist said in Concept for analyze several XML messages, sometimes incomplete.:
- cumulate the data in a buffer until you have a full message
- extract the message from the buffer
OK, Do you have a good sample?
@RobertSommer
Yes, it would be a ring buffer, it is also possible that no XML data is coming, then ignore it. How can I solve this? With example. THANKS.<ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> </ROOT> <ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> </ROOT> 000000 <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> <ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> 00000000 </ROOT> 000000 <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> artial receipt of messages"> <START_REQ task="1" program="0178" /> **00000000** </ROOT> XXXX000000 <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> <ROOT info="P
-
@RobertSommer
Yes, it would be a ring buffer, it is also possible that no XML data is coming, then ignore it. How can I solve this? With example. THANKS.<ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> </ROOT> <ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> </ROOT> 000000 <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> <ROOT info="Partial receipt of messages"> <START_REQ task="1" program="0178" /> 00000000 </ROOT> 000000 <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> artial receipt of messages"> <START_REQ task="1" program="0178" /> **00000000** </ROOT> XXXX000000 <ROOT info="Partial receipt of messages"> <START_REQ task="2" program="0178" /> </ROOT> <ROOT info="P
@RobertSommer said in Concept for analyze several XML messages, sometimes incomplete.:
it is also possible that no XML data is coming, then ignore it. How can I solve this?
What exactly do you mean by this? If no data comes then you won't receive any data and won't have anything to parse. Do not do a blocking read if you have to wait for data, use a readyRead() signal.
-
@RobertSommer said in Concept for analyze several XML messages, sometimes incomplete.:
it is also possible that no XML data is coming, then ignore it. How can I solve this?
What exactly do you mean by this? If no data comes then you won't receive any data and won't have anything to parse. Do not do a blocking read if you have to wait for data, use a readyRead() signal.
@JonB said in Concept for analyze several XML messages, sometimes incomplete.:
What exactly do you mean by this?
I send and receive XML messages via socket, which I have to evaluate. There may be 0000 between the messages, other characters that are not necessary for XML. Presumably buffer with 000
The idea is to read <Root> XXXXXX </Root>.
It may be that two messages come at once, too fast.
How can I solve this? RingBuffer? Do you have a good example of how to solve this?