Skip to content

Template protocol with xml data. #1456

Answered by thesamprice
thesamprice asked this question in Q&A
Discussion options

You must be logged in to vote

Ok i got something that worked.

I ended up creating a second protocol to strip off the XML flags.

  class StripXML < Protocol
    # def read_packet(packet)
    #   puts packet
    #   return packet
    # end
    def read_data(input)
      input = input.strip()
      status = ""
      data = ""
      error = ""

      if input.match(/\<status\>/)
        status = input[/\<status\>\s*(.*)\s*\<\/status\>/,1]
      else
        return input
      end

      if input.match(/\<data\>/)
        data = input[/\<data\>\s*(.*)\s*\<\/data\>/,1]
      end

      if input.match(/\<error\>/)
        error = input[/\<error\>\s*(.*)\s*\<\/error\>/,1]
      end

      res =  status + "," + data + "," + er…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ghost
Comment options

@thesamprice
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant