Announcement

Collapse
No announcement yet.

how to parse xml data ?

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

    how to parse xml data ?

    Got it , SOLVED



    Hello all,

    i don;t know where to start at all..
    i did found a lot of scripts for parsing the xml data but i can't get it to work..

    here is the url where the data is coming from and how its formatted.

    the url is http://192.168.x.x/core/modules

    <modules><module id="cccd9a140dxxxx599e066afca56"><vendor_name>Ene5\XS21 0ESMR5.0</vendor_name><vendor_model>Ene5\XSxxxSMR5.0</vendor_model><hardware_version/><firmware_version/><created_date>2019-02-21T16:22:43.123+01:00</created_date><modified_date>2019-04-07T12:28:00.275+02:00</modified_date><deleted_date/><services><electricity_interval_meter id="bd521e53xxx9a662023c5"><measurement log_date="2019-04-07T12:00:00+02:00" unit="Wh" interval="PT300S" directionality="produced" tariff_indicator="nl_offpeak">956.000</measurement><measurement log_date="2019-04-07T12:00:00+02:00" unit="Wh" interval="PT300S" directionality="produced" tariff_indicator="nl_peak">0.000</measurement><measurement log_date="2019-04-07T12:00:00+02:00" unit="Wh" interval="PT300S" directionality="consumed" tariff_indicator="nl_offpeak">0.000</measurement><measurement log_date="2019-04-07T12:00:00+02:00" unit="Wh" interval="PT300S" directionality="consumed" tariff_indicator="nl_peak">0.000</measurement></electricity_interval_meter><electricity_cumulative_meter id="317687xxxx9xx838cba3c92c9"><measurement log_date="2019-04-07T12:25:00+02:00" unit="Wh" directionality="produced" tariff_indicator="nl_offpeak">92572.000</measurement><measurement log_date="2019-04-07T12:25:00+02:00" unit="Wh" directionality="produced" tariff_indicator="nl_peak">186981.000</measurement><measurement log_date="2019-04-07T12:25:00+02:00" unit="Wh" directionality="consumed" tariff_indicator="nl_offpeak">131788.000</measurement><measurement log_date="2019-04-07T12:25:00+02:00" unit="Wh" directionality="consumed" tariff_indicator="nl_peak">96659.000</measurement></electricity_cumulative_meter><electricity_point_meter id="064fd82e2xxxx90c0f26e2c75104"><measurement log_date="2019-04-07T12:27:53+02:00" unit="W" directionality="produced">2422.000</measurement><measurement log_date="2019-04-07T12:27:53+02:00" unit="W" directionality="consumed">0.000</measurement></electricity_point_meter></services><protocols><dsmrmain id="516833c0bb2840bdxxxxx59d8365295b3"><serial>E0047xxxxx47 4 22 718</serial><dsmrmbuses>
    </dsmrmbuses></dsmrmain></protocols></module></modules>


    this is what i need, only the value's ofcourse.:
    like to return in hs.writelog.

    "nl_offpeak">956.000</measurement>
    nl_peak">0.000</measurement>
    "nl_offpeak">0.000</measurement>
    nl_peak">0.000</measurement>
    tariff_indicator="nl_offpeak">92572.000<
    tariff_indicator="nl_peak">186981.000<
    tariff_indicator="nl_offpeak">131788.000
    tariff_indicator="nl_peak">96659.000
    directionality="produced">2422.000<
    directionality="consumed">0.000


    right now i have this code ;
    Code:
    Sub Main(ByVal Parms As String)
    Dim xmlDoc As New XmlDocument()
    Dim strdata as String
    Dim PageXML as String
    Dim XML_Feed as integer = 1
    Dim url = "http://usernm:pass@192.168.1.13"
    Dim page = hs.GetURL(url,"/core/modules",FALSE,80)
    hs.WriteLog ("test", page)
    
    End Sub
    and returns like this :
    Code:
    Apr-07 12:55:51           Test     Ene5\XS210ESMR5.0 Ene5\XS210ESMR5.0 2019-02-21T16:22:43.123+01:00 2019-04-07T12:55:51.824+02:00 1967.000 0.000 0.000 0.000 93583.000 186981.000 131788.000 96659.000 2495.000 0.000 E0047000047422718



    If someone can show me how i can parse this ?
    with json its easy but with xml i never done that




    regards.
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

    #2
    As you have Datascraper installed, why not use that?
    Jon

    Comment


      #3
      Originally posted by jon00 View Post
      As you have Datascraper installed, why not use that?
      hi jon,

      i would love t use that.. but it doesnt work at all..
      it does not even scrape nothing and i don't know why ...
      i did test for a long time.

      getting this error for example:
      Apr-07 13:26:46 Jon00_DataScrape Cannot obtain data from path: http://smile:*******@192.168.1.13/core/modules
      Apr-07 13:26:46 Error Exception in GetURLIE getting retrieved web page's content: Public member 'InnerHTML' on type 'DBNull' not found.


      i did test it out with this code just to check if there is indeed a issue :

      Code:
      ECHO
      cd C:\Program Files (x86)\GnuWin32\bin
      ECHO
      wget "http://smile:****@192.168.1.13:80/core/modules" -O C:/PROGRA~2/"HomeSeer HS3"/Data/test55.txt
      ECHO
      but it gets the full page xmldata correctly like it should.


      regards
      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




      HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

      Comment


        #4
        Do you have to use GetURLIE? (Set UseIE=0)
        Jon

        Comment


          #5
          Originally posted by jon00 View Post
          Do you have to use GetURLIE? (Set UseIE=0)
          yes, nothing shows up in the log when i do that aswell, and no data file created
          Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
          Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




          HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

          Comment


            #6
            So is it actually a https site (redirected from http)?
            Jon

            Comment


              #7
              hi jon,

              its normal http, i really dont know why it doesnt work with the data scraper.

              but i got the script going.

              i really need to see why the scraper doesnt work
              Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
              Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




              HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

              Comment

              Working...
              X