Announcement

Collapse
No announcement yet.

Creating devices with xml results for google calendar

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

    Creating devices with xml results for google calendar

    Hi!

    I have found a php script for google calendar.
    This script is connecting to google calendar and show in a xml output:
    -Day's events
    -Tomorrow events

    I want tu use these informations in hstouch .
    (Hstouch can only read rss feed)

    My idea is , with a script, to create a device per event.

    To launch my script, i must launch a internal url such as: http://192.168.1.15:88

    an example of result:



    <?xml version="1.0" encoding="UTF-8"?>
    <conges>
    <aujourdhui>supernew2</aujourdhui>
    <demain>Anniversaire Raymond</demain>
    <demain>he hooo</demain></conges>

    Thanx a lot !!
    Last edited by pawnies20; August 22, 2012, 03:19 AM.

    #2
    I can't help with your specific example but for a start you need to add a reference to the System.XML namespace.

    This is a short example script that can read RSS/XML data. You will need to learn another mini language called XPath. When you try and navigate through an XML document then it needs to be done by an XPath reference, if you struggle then there is an application called XPathBuilder that can help you - I found it quite difficult to get my head around it to start with. I would suggest trying to get the data into the HS log first, if you can figure this out then writing it to a device should be easy.

    Code:
    Imports System.XML
    
    Sub Main(ByVal Parms As Object)
    
    Dim XMLNews As New XmlDocument
    Dim XMLNewsNodeList As XmlNodeList
    Dim XMLNewsNode As XmlNode
    
    XMLNews.Load("http://feeds.bbci.co.uk/news/uk/rss.xml")
    
    XMLNewsNodeList = XMLNews.SelectNodes("/rss/channel/item")
    
    For Each XMLNewsNode In XMLNewsNodeList
    
    hs.writelog("News", XMLNewsNode.Item("title").InnerText)
    
    Next
    
    End Sub

    Comment


      #3
      Check that you have added the reference to the System.Xml file and also are you running the script as a .vb file?

      Comment


        #4
        Ok Mr happy.
        Thanx

        It works but i'm still having a problem.

        I use this scriptbu tonly first event is read "bib" and no "bib2"??



        Imports System.XML
        Sub Main(ByVal Parms As Object)
        Dim XMLNews As New XmlDocument
        Dim XMLNewsNodeList As XmlNodeList
        Dim XMLNewsNode As XmlNode
        XMLNews.Load("http://localhost:88/")
        XMLNewsNodeList = XMLNews.SelectNodes("/conges")
        For Each XMLNewsNode In XMLNewsNodeList
        hs.writelog("News", XMLNewsNode.Item("demain").InnerText)
        Next
        End Sub




        <?xml version="1.0" encoding="utf-8" ?>
        - <conges>
        <aujourdhui>Anniversaire Raymond</aujourdhui>

        <aujourdhui>he hooo</aujourdhui>

        <demain>BIB</demain>

        <demain>BIB2</demain>

        </conges>

        Comment


          #5
          It works now.
          I had to change xml file in this way:

          <?xml version="1.0" encoding="utf-8" ?>
          - <conges1>
          - <conges>
          <aujourdhui>Anniversaire Raymond</aujourdhui>

          </conges>


          - <conges>
          <aujourdhui>he hooo2</aujourdhui>

          </conges>


          - <conges>
          <aujourdhui>toto2</aujourdhui>

          </conges>


          - <conges2>
          <demain>BIB</demain>

          </conges2>


          - <conges2>
          <demain>BIB2 2</demain>

          </conges2>


          - <conges2>
          <demain>titi2</demain>

          </conges2>


          </conges1>

          Script become:

          Imports System.XML
          Sub Main(ByVal Parms As Object)
          Dim XMLNews As New XmlDocument
          Dim XMLNewsNodeList As XmlNodeList
          Dim XMLNewsNode As XmlNode
          XMLNews.Load("http://localhost:88/")
          XMLNewsNodeList = XMLNews.SelectNodes("/conges1/conges")
          For Each XMLNewsNode In XMLNewsNodeList
          hs.writelog("News", XMLNewsNode.Item("aujourdhui").InnerText)
          Next
          End Sub

          Now i can read google calendar's events in homeseer or directly in xml in hstouch !!!

          Thanx Mr Happy

          Comment

          Working...
          X