Parsing XML Data from Website

Tags: #<Tag:0x00007f6182414200> #<Tag:0x00007f6182414020> #<Tag:0x00007f617a1bbe98>
  • Platform information:

    • OS:WINDOWS 8
    • openHAB version: 2
  • Issue of the topic: Trying to retrieve XML Data from this site and not getting anything, also dont seem to see the item created in the panel.

The XML is here

XPATH that im using that seems to work on the tester - /Root/DataSet/Data/Value/number()

rule "Convert XML to Item Type Number"
    Item Price_xml changed
    // use the transformation service to retrieve the value
    // Simple
    val mytest = transform("XPATH", "/*[name()='Root']				
                                    Price_xml.state.toString )  
    // Fully qualified
    val mytest = transform("XPATH", "/*[local-name()='Root'    and namespace-uri()='']
                                     /*[local-name()='DataSet' and namespace-uri()='']
                                     /*[local-name()='Data'      and namespace-uri()='']
                                     /*[local-name()='Value'      and namespace-uri()='']
                                    Price_xml.state.toString )

    // post the new value to the Number Item
    Price.postUpdate( newValue )


//XPATH /Root/DataSet/Data/Value/number() TESTED ON WEBSITE
String  Price_xml "Price [XPATH(/*[name()='Root']/*[name()=DataSet']/*[name()='Data']/*[name()=Value']/):%s $]" {...}
Number  Price "Price [%.1f $]"

EDIT: I have updated some of the obvious errors i have made with the code, as i had the XPATH expression totally messed up.

If i can get any input on what i might be doing wrong, it will be greatly appreciated.
Thanks guy!

Maybe I don’t understand it, but where do you get the XML from the website?

Sorry, I meant how the XML is stored in the Price_xml item? I don’t see a http action or the usage of the http binding.



Ok, I think you get some things wrong.

  1. your file should be named like http.cfg. Is it in the services directory?
  2. Inside the http.cfg you should have that:
  3. Your item must reference the configuration:

But I don’t know if you can get the while XML using that way. I’m using the http action an a role with a cron job.

Yes, i have that inside the http.cfg file.

The newValue attribute doesn’t exist.