XML handling question


#1

1) Give a description of the problem
Getting the xml data, need to know how to utilize it

2) What is the desired behaviour?
Match the first five characters of data in the response to make something happen.

3) What is happening/not happening?
I’m not able to correctly extract the first five characters of $response.

**4) Post a Green Snapshot of the piston

And here is the variable after running the piston by powering on the unit:

5) Attach logs after turning logging level to Full

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

So in the Variables section, I simply wish to grab ON NE, which is the first two (power status) plus the space plus the next two (NEt music), and put it into another variable (string var X33out).

Once I have that, the Matches section can act on it.


#3

If I’m understanding this correctly, this should work.

X33out = mid(Pwr,0,5)


#4

That generates the same evaluation error as my previous expression:


#5

Got it, I based that off of the Pwr in your local variable screenshot.


#6

Pwr is identical to $response. I tried Pwr as a string variable, without success.


#7

Pls paste this as plain text so I can play with it tomorrow, if I can find a way to mock the response.


#8

Here it is

+223ms ║║<?xml version="1.0" encoding="utf-8" ?>
+223ms ║║
+223ms ║║OFF
+223ms ║║TUNER
+223ms ║║Absolute
+223ms ║║-60.0
+224ms ║║off
+224ms ║║

#9

And I see the issue with what I’m grabbing. Which is why I need to know how to handle the xml correctly.

That said, if I do Mid(Pwr,61,2) I get the Power status. Currently ON
And Mid(Pwr,104,3) I get the input. Currently TUN (Tuner).

If I put those together I get what I need. EDIT: got it. But still would like to know if there’s a better way to handle it.


#10

Duplicate, ignore


#11

I forget what functions webCoRE has built-in. Ideally I’d want to pull out the values of interest with a regular expression, but failing that trying to locate particular tags in the response string would do.


#12

The good thing here is that, while this is not really a fixed-length file, from the standpoint of what I wish to do it behaves like one. Power status of ON, plus the first two characters of which input is being utilized, allows me to use MATCHES to a) turn on Zone2, and b) power up the second amp for distribution - along with setting volumes appropriately and whatnot.

Likewise, power status of OFF will generate a usable code trigger (OFCD, for example) on which I can have Webcore perform actions such as shutting off the second amp. Combined with voice control (Alexa, turn off Denon), it will allow real flexibility.