Parse XML IOResponse

Home Forums V-Control General Parse XML IOResponse

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #7112
    atallon10
    Participant

    I am using an Abekas MIRA playback/record server. It’s responses are formatted as an XML string. When I request a clip list from the machine, I would like to parse the response in order to use it for an Automatic Parameter in the Device Editor. From the attached example, I need to parse the clip names (highlighted in green) that are listed between all the <ClipID> and </ClipID> tags (highlighted in yellow). As I am not so familiar with BASIC commands, could someone help me figure out how to parse this information?

    Thanks,
    Alex

    Abekas-MIRA-IOResult-Example

    Attachments:
    #7160
    JonasStade
    Participant

    1. Use NthField() as a sorting function. Use <ClipId> as sorting identifier, then select slot 2, should be something like
    dim clipid as string
    clipid=NthField(ioresult,“<ClipId>“,2)

    And then you have two options. First you can set </clip> as an acknowledge in the command driver, so VControl stops reading the
    Ioresult from this point on/cut the rest of the XML of, because it is the command end indicator, were the ack event would take over. Or you do another NthField request on </ClipId> and select slot 1. then fill the value into the device driver and you finish. Would be nice if you could response if it is working. The last time I write huge amount of text to this Forum and no working response etc.

    #7191
    Dierk Walter
    Keymaster

    Jonas’ clue is absolutely correct. But we have the problem here that NthField is NOT case sensitive. And in your return string you have clipid and ClipID, which is the same for the NthField function. This makes it really complex to parse the string.

    A full description of the clip looks like this:

    so you can loop through your result such as

    • This reply was modified 4 months, 1 week ago by Dierk Walter.
    • This reply was modified 4 months, 1 week ago by Dierk Walter.
    • This reply was modified 4 months, 1 week ago by Dierk Walter.
    #7196
    atallon10
    Participant

    Thank you Jonas and Dierk. I will try this as soon as possible.

    #8487
    atallon10
    Participant

    So I’ve had a chance to try your suggestions and am having some issues. My main issue right now is that the count I’m getting from CountFields is unreliable. The playback server has 519 clips in it and I get a different clip count every time I run it. For now, I am just testing CountFields as a command and not an ack command so that I can see what is going on. The other curious thing is that using ioresult in CountFields does not work for me. I have to declare a variable using the Received device variable. Any thoughts?

    Thanks,
    Alex

    #8493
    Dierk
    Participant

    If you have 519 clips, then the length of the total response is very big. The standard frame size of an Ethernet packet is 1500 bytes. I assume that V-Control thinks the Acknowledge is complete before the whole Acknowledge is received.

    To solve this you need something such as a termination character or sequence. I can imagine that chr(13) is not suitable because it might be multiple times in the Acknowledge.

    You need to find a single character or a sequence of characters that marks the end of the transmission and define that as TermChar.

    At Configure->Options in the System Tab, there is also a “Maximum Channel Buffer Size” value, set to 600 by default. If the length of the Acknowledge exceeds this size, then the Acknowledge will be dropped. So you might need to increase this value.

    #8510
    atallon10
    Participant

    Thank you Dierk. I will increase the Maximum Channel Buffer Size. And, forgive my lack of VB knowledge, but could you explain to me how to set a TermChar?

    Thanks,
    Alex

    #8511
    Dierk
    Participant

    Oh sorry, with TermChar I mean a termination Character, but this is not the terminology used in V-Control. In V-Control this means the “Ack in Hex” field. In this field you have to enter one or more hex values that determine the end of the acknowledge.

    #8728
    atallon10
    Participant

    Thanks for clearing that up for me. This has been a great exercise in Basic. I an now using a different playback server that only has 84 clips on it. The CountFields operation is now consistently giving me the correct count. The only issue I am having is that the For…Next loop does not seem to be working. Below is my code. I added the ShowMessage in order to monitor the output of CountFields. Please let me know if you see anything that I am missing in order for this to work. Thanks again for your help.

    dim tmp, rcv, count as string
    dim i as integer

    rcv = GetDeviceVar(“Received”)

    For i = 1 to CountFields(rcv,”</ClipID>&h0D&h0A</clipid>&h0D&h0A</reply>”) -1
    tmp = NthField(rcv,”</ClipID>”,1)
    tmp = replaceAllB(tmp,”<ClipID>”,”:”)
    tmp = NthField(tmp,”:”,2) + “;”
    ChangeCMD_MinMax(“LoadClip”,”P2″,tmp)
    count = Str(i)
    ShowMessage(” ” + count)
    Next

    #8729
    atallon10
    Participant

    I just read what I wrote an realized I needed to elaborate a little more. By the For….Next loop not working , I mean that the code inside the loop works, but I only get the first clip name instead of all 84 clips. So to me it seems that the code is not looping but just running once.

    Regards,
    Alex

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.