Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. MessageToXml Xml Parsing Error

messageToXml xml parsing error

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By xeniter , 2 October, 2022
Forums
Gurux.DLMS

hi,

decoded frame from a austria eww (ewerk wels) im350 smartmeter

python code:
xml = decrypt.messageToXml(GXByteBuffer.hexToBytes(data))
print(xml)
tree = ET.fromstring(xml)

when i tried to parse the xml i get following error:

xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 16, column 8

put it xml string into https://www.xmlvalidation.com:

16: 9 The string "--" is not permitted within comments.
=> looks like a comment in a comment is not allowed?

is it easy possible to get xml only from encrypted data?

xml data:

<HDLC len="6F" >
<TargetAddress Value="67" />
<SourceAddress Value="4011" />
<!--S frame.-->
<FrameType Value="13" />
<PDU>
<!--
IDIS system title:
Manufacturer Code: SMS
Function type: Disconnector extension, Load Management extension, Multi Utility extension
Serial number: 188393
-->
<!--Decrypt data: 0F 00 02 82 55 0C 07 E6 09 1B 02 00 0F 11 00 FF 88 80 02 0A 09 06 00 06 19 09 00 FF 09 08 31 38 30 32 39 35 35 33 09 04 00 0F 11 00 09 05 07 E6 09 1B 02 06 01 90 9B FE 06 00 00 30 6A 06 00 3B 23 63 06 00 22 33 75 06 00 00 02 AF 06 00 00 00 00
<DataNotification>
<LongInvokeIdAndPriority Value="00028255" />
<!--09/27/22 00:15:17-->
<DateTime Value="07E6091B02000F1100FF8880" />
<NotificationBody>
<DataValue>
<Structure Qty="0A" >
<!--0.6.25.9.0.255-->
<OctetString Value="0006190900FF" />
<!--bytearray(b'18029553')-->
<OctetString Value="3138303239353533" />
<OctetString Value="000F1100" />
<!--09/27/22-->
<OctetString Value="07E6091B02" />
<UInt32 Value="01909BFE" />
<UInt32 Value="0000306A" />
<UInt32 Value="003B2363" />
<UInt32 Value="00223375" />
<UInt32 Value="000002AF" />
<UInt32 Value="00000000" />
</Structure>
</DataValue>
</NotificationBody>
</DataNotification>
-->
<GeneralGloCiphering>
<SystemTitle Value="534D53677002DFE9" />
<CipheredService Value="200002825507E4A90965D819AF74E8E8325ACA4D00B0DF6B9D3B7F847F95DEE24CA51C883641B7BE98BC52C07A2D7BEE229244A6CCEA7CF7130CCDBA5C35EAE2CAA1EA379879EB672FD78B494D6136BC9AD7FBA61FF2" />
</GeneralGloCiphering>
</PDU>
</HDLC>

Profile picture for user Kurumi

Kurumi

3 years 8 months ago

Hi,

Hi,

The idea of messageToXml method is to visualize the received frame as XML. It's not planned that you can use it later because there are values that are changing every time.

I understand your idea in the push message. I believe that you want to search for values from the comments and save them. I propose that you use getData of the GXDLMSClient. You can get the example from here:

https://github.com/Gurux/Gurux.DLMS.Python/blob/340f98a30a9a4095256ae29…

BR,
Mikko

xeniter

3 years 8 months ago

hi, thx for the fast answer,

hi, thx for the fast answer, unfortunate i don't use GXDLMSClient

i use only GXDLMSTranslator to decrypt my message,
the data message i get every second via serial from my siemens im350 smartmeter
use a esp8266 for readout and forward it to tcp, see:
https://github.com/xeniter/eww_ewerk_wels_smartmeter_readout

example of decoding one message:
data = "7ea070cf0002002313e0c7e6e700db08534d53677002dfe956200002825507e4a90965d819af74e8e8325aca4d00b0df6b9d3b7f847f95dee24ca51c883641b7be98bc52c07a2d7bee229244a6ccea7cf7130ccdba5c35eae2caa1ea379879eb672fd78b494d6136bc9ad7fba61ff29b3b7e"

xml = ""
# decrypting received data
#decrypt = GXDLMSTranslator(TranslatorOutputType.STANDARD_XML)
decrypt = GXDLMSTranslator(TranslatorOutputType.SIMPLE_XML)
decrypt.comments = True
decrypt.security = enums.Security.ENCRYPTION
decrypt.blockCipherKey =GXByteBuffer.hexToBytes("75FD8711381B3FB18C101AEBD192C3AB")

xml = decrypt.messageToXml(GXByteBuffer.hexToBytes(data))
print(xml)

Goal would be here to parse values from the xml result and forward/push it for example somehow to home assistent, however when parsing it i get a xml parse error cause of comments in comments xml.
Will try maybe simple regex for parsing but this is more like workaround instead reading valid xml with a parser.

Profile picture for user Kurumi

Kurumi

3 years 8 months ago

Hi,

Hi,

I was thinking about this and it's possible to start using #comment if there are internal comments. That will solve your problem. Testing will take some time, but this will be released next week after the new version from Gurux.DLMS.AMI is released.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin