Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Concept for analyze several XML messages, sometimes incomplete.
Forum Updated to NodeBB v4.3 + New Features

Concept for analyze several XML messages, sometimes incomplete.

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 122 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RobertSommer
    wrote last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      1
      • SGaistS SGaist

        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

        R Offline
        R Offline
        RobertSommer
        wrote last edited by
        #3

        @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?

        R 1 Reply Last reply
        0
        • R RobertSommer

          @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?

          R Offline
          R Offline
          RobertSommer
          wrote last edited by
          #4

          @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
          
          JonBJ 1 Reply Last reply
          0
          • R RobertSommer

            @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
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote last edited by
            #5

            @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.

            R 1 Reply Last reply
            0
            • JonBJ JonB

              @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.

              R Offline
              R Offline
              RobertSommer
              wrote last edited by RobertSommer
              #6

              @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?

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved