Value of a string-Item from xml-file via XPath

Dear all,

i want to transform current Song-Title, Artist and Album from an autogenerated xml-file:

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

<now_playing playing="1" timestamp="2016-10-28T12:59:41Z">
	<song timestamp="2016-10-28T12:59:40Z">
		<title>Salva Mea</title>
		<album>Salva Mea</album>

i tried this with the following .items-file:

String 21_Title "Title [%s]"  { http="<[[1]/title)]" }
String 21_Artist "Artist [%s]"  { http="<[[1]/artist)]" }
String 21_Album "Artist [%s]"  { http="<[[1]/album)]" }

but nothing happens (XPath Transformation are installed), not even an error in the log as i got when i tried to write a xslt-Transformation.

Unfortunately the XPath-Transformationof oH1 or oH2 isn’t documented everywhere - i found only this in the wiki:

Do anybody works with oH2, XML-Files und XPATH-Transformation and can give me a working example?


I have been using XSLT, though I suppose I could be using XPATH for all but one of mine.

In XSLT though the path starts with “//”, not just “/”. I’m really digging down in my memory and can’t remember why I needed to do that. You can give it try and see if that works.

Usually, at least with the XSLT, I’ll get an error in the log if the path is wrong so I’m not sure this will help.

Thank you for your reply.

Meanwhile i found out the the autogenerated XML of the iTunes-plugin did not deliver valid xml. To cut the output was the solution to get the current title to my oH2-Item:

		<title>Enjoy the silence</title>

That is my working .item with XPath:

String 21_Title "Titel [%s]"  { http="<[]" }

And here is the expected change in the log:
23:26:42.136 [INFO ] [marthome.event.ItemStateChangedEvent] - 21_Title changed from Whiskey and Pills to Enjoy the silence

Now i have to find a good solution to deliver current tracks from iTunes to oH2, meanwhile im very impressed about the possibilities of XPath inside oH2 :smile:

1 Like