Announcement

Collapse
No announcement yet.

Reading XML file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Reading XML file

    I'm trying to put some data from an XML file into some virtual devices. Normally i have no problem doing this but in this case I can't figure it out.

    I use the following script:

    PHP Code:
    sub main()

        
    strpath "http://xml.buienradar.nl"
        
        
    Set oXML CreateObject("Microsoft.XMLDOM")
        
    oXML.async False
        oXML
    .load(strpath)
        
        
    Set node_dagplus1 oXML.selectSingleNode("buienradarnl/weergegevens/verwachting_meerdaags/dag-plus1/icoon")    
        
    hs.SetDeviceString "w10"node_dagplus1.text
        
    End sub 
    It decodes http://xml.buienradar.nl

    The line I'm looking for is:
    PHP Code:
    <icoon ID="b">http://xml.buienradar.nl/icons/b.gif</icoon> 
    The problem is that I want "b" as my device string and not "http://xml.buienradar.nl/icons/b.gif".

    Any ideas?

    #2
    ID is an attribute. "http://xml.buienradar.nl/icons/b.gif" is the innertext of the <icoon> element.

    So, try adding ".Attributes("ID").Value" to the end of your selectSingleNode call.
    I may have the syntax wrong, so let us know...
    HS4Pro on a Raspberry Pi4
    54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
    Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

    HSTouch Clients: 1 Android

    Comment


      #3
      Do you mean like this:

      Set node_dagplus1 = oXML.selectSingleNode("buienradarnl/weergegevens/verwachting_meerdaags/dag-plus1/icoon").Attributes("ID").value

      It isn't working, but you helpt me in the right direction by pointing out that it is a attribute.

      Thanks so far.

      Comment


        #4
        Found it!

        wrong line.

        hs.SetDeviceString "w10", node_dagplus1.Attributes.getNamedItem("ID").Text

        So:
        PHP Code:
        sub main()

            
        strpath "http://xml.buienradar.nl"
            
            
        Set oXML CreateObject("Microsoft.XMLDOM")
            
        oXML.async False
            oXML
        .load(strpath)
            
            
        Set node_dagplus1 oXML.selectSingleNode("buienradarnl/weergegevens/verwachting_meerdaags/dag-plus1/icoon")
            
        hs.SetDeviceString "w10"node_dagplus1.Attributes.getNamedItem("ID").Text
            Set node_dagplus2 
        oXML.selectSingleNode
            
        End sub 
        Thanks!

        Comment


          #5
          cool! glad it's working for you!
          HS4Pro on a Raspberry Pi4
          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

          HSTouch Clients: 1 Android

          Comment

          Working...
          X