Cannot get xml content as string

Hi guys,

I am using OpenHAB 2 on a RasPi 3.

I am getting mad about a simple task:
I want to get the content of any xml, e.g.

For this purpose I installed the HTTP binding.
I have no special entries in http.cfg.

Then I added an item:

String Test4 {http="<[]"}

I don’t need any transformation, just want to get the whole xml, which in this example should be “FM;stream.mp3”.

Unfortunately my sitemap always returns “null”:

Text      item=Test4              label="HTTP-Test4 [%s]"

Can anybody help me out and give me a hint about what I am doing wrong?
Thanks a lot!

Yes you do,
You need to extract the tag
See the xpath tranformation docs:

<liveStreams version="2.0"><stream><label>FM</label><url>;stream.mp3</url></stream></liveStreams>

And even if you didn’t need the XPath transformation, it is not optional in the http binding config on the binding.

You have to have something there. If you don’t want to transform you may be able to use “default” or you will have to use the REGEX transform and pass the full text.

String Test4 {http="&lt;[]"}
String Test4 {http="&lt;[*))]"}

Thanks to both of you, Vincent and Rich.

I already tried “:default” as well as several different REGEX expressions in the item definition, including the one you propose.
Unfortunately neither worked. My sitemap always shows “-”.

It must be something else, but I just cannot find out what is wrong.
I even uninstalled and reinstalled the http-binding in PaperUI.

I am afraid it is some stupid mistake…

Maybe I do have to make some modifications in the http.cfg file?

Are you looking in openhab.log for errors? The HTTP binding is pretty good are reporting errors.

You have to have something after the 1000 or else it is a malformed binding config (which is almost certainly reported in the logs).

I’m not certain if default is allowed for incoming bindings which is why I also listed the REGEX noop version.

Do you actually have the REGEX transform installed?

Since you will need to use the XPATH transform anyway to extract that string from the XML, have you tried to make it work with that? Again, make sure you install the transform.

Yes, openhab.log does not report any errors.
But strangely even without something after the 1000, no error was reportet (…?)

As mentioned, neither the “default” nor the REGEX worked.

REGEX is installed, I also uninstalled and reinstalled it just to be sure.

I wanted to avoid to dive into yet another transformation, that is why I wanted to get anything back with REGEX.

This works for me:
Note the <

String Test4 {http="<[*))]"}

I get:

<?xml version="1.0" encoding="UTF-8"?>
<liveStreams version="2.0" xmlns="">

And that:

String Test4 {http="<[*<url>(.*)</url>.*)]"}


Thanks, Vincent!

Unfortunately it still does not work, even with both items definitions you posted.
Could you please also post your line in the sitemap, just to be sure?
Mine just returns “-”.

In addition, I have a rule defined, which contains the line

logInfo("Test", Test4.state.toString)

This returns “NULL” in the openhab.log.

I am starting to get mad about this…

Post your http.cfg please

After I unistalled and re-installed the HTTP binding in PaperUI it works!!!
I don’t know why, because I un/re-installed it already before.

No I finally also get the HTTP messages in the log.

Your support helped me a lot to narrow down the possible reasons, as you confirmed my items incl. the REGEX should work.

Thanks again!

Regarding the http.cfg, I understood there is no special code needed?

No special code needed.
Please mark the thread as solved, thanks