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. GXDLMSTranslator: MessageToXml Returns Invalid XML

GXDLMSTranslator: MessageToXml returns invalid XML

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 slip81 , 31 August, 2021
Forums
Gurux.DLMS

Hi,
I'm trying to convert DLMS hex-string to XML using GXDLMSTranslator. Sometimes it appears that MessageToXml method returns string, which is not a proper XML-formatted data.

For example:

1) source DLMS string:

7E-A0-71-21-02-21-B8-82-4C-00-00-00-00-00-00-00-00-15-00-00-00-00-00-07-C6-08-15-00-00-00-00-00-05-67-24-15-00-00-00-00-00-00-00-00-15-00-00-00-00-00-00-00-00-15-00-00-00-00-00-00-00-00-15-00-00-00-00-00-05-67-24-15-00-00-00-00-00-2A-1F-3E-15-00-00-00-00-00-01-F9-3A-15-00-00-00-00-00-07-C6-08-15-00-00-00-00-00-05-67-24-06-00-00-00-12-3E-48-7E

2) result XML string (fragment):

<PDU>
<Data="000..." />
</PDU>

XML validation failes for this result with message:
"The '=' character, hexadecimal value 0x3D, cannot be included in a name"

so a valid XML should like like this:

<PDU>
<Data Value="000..." />
</PDU>

Is there any way I can configure GURUX library to return valid XML ?
Thanks !

Profile picture for user Kurumi

Kurumi

4 years 9 months ago

Hi,

Hi,

The reason is that your data is not valid DLMS PDU. Because LLC bytes are missing I believe that your PDU is coming in frames and the previous frame is missing. Because part of the data is missing, data can't be shown as XML. You need to give all frames to the parser so it can be parsed.

BR,
Mikko

slip81

4 years 9 months ago

Hi,

Hi,
thanks for quick response !

However I'd like to be a little more specific: indeed, my posted example is one of a multi-part response, and each separate part of that pesponse contains valid XML, except of one part. Here they are:

<HDLC len="134" >
<TargetAddress Value="16" />
<SourceAddress Value="144" />
<!--I frame.-->
<FrameType Value="BE" />
<NextFrame Value="C402C10000000001008202C90104021A090C07E5061501000000008000001500000000002353A41500000000000000001500000000000000001500000000000000001500000000002353A415000000000001F93A15000000000000000015000000000000000015000000000000000015000000000001F93A1500" />
</HDLC>

<HDLC len="134" >
<TargetAddress Value="16" />
<SourceAddress Value="144" />
<!--I frame.-->
<FrameType Value="B0" />
<NextFrame Value="0000000007C60815000000000000000015000000000000000015000000000000000015000000000007C60815000000000003A7C215000000000000000015000000000000000015000000000000000015000000000003A7C21500000000002353A415000000000001F93A15000000000007C60815000000000003A7C206" />
</HDLC>

<HDLC len="134" >
<TargetAddress Value="16" />
<SourceAddress Value="144" />
<!--I frame.-->
<FrameType Value="B2" />
<NextFrame Value="00000012021A090C07E50616020000000080000015000000000026C72415000000000000000015000000000000000015000000000000000015000000000026C72415000000000001F93A15000000000000000015000000000000000015000000000000000015000000000001F93A15000000000007C608150000000000" />
</HDLC>

<HDLC len="134" >
<TargetAddress Value="16" />
<SourceAddress Value="144" />
<!--I frame.-->
<FrameType Value="B4" />
<NextFrame Value="00000015000000000000000015000000000000000015000000000007C60815000000000004807D15000000000000000015000000000000000015000000000000000015000000000004807D15000000000026C72415000000000001F93A15000000000007C60815000000000004807D0600000012021A090C07E5061703" />
</HDLC>

<HDLC len="134" >
<TargetAddress Value="16" />
<SourceAddress Value="144" />
<!--I frame.-->
<FrameType Value="B6" />
<NextFrame Value="000000008000001500000000002A1F3E1500000000000000001500000000000000001500000000000000001500000000002A1F3E15000000000001F93A15000000000000000015000000000000000015000000000000000015000000000001F93A15000000000007C60815000000000000000015000000000000000015" />
</HDLC>

<HDLC len="112" >
<TargetAddress Value="16" />
<SourceAddress Value="144" />
<!--I frame.-->
<FrameType Value="B8" />
<PDU>
<Data="0000000000000015000000000007C6081500000000000567241500000000000000001500000000000000001500000000000000001500000000000567241500000000002A1F3E15000000000001F93A15000000000007C6081500000000000567240600000012" />
</PDU>
</HDLC>

First 5 frames contains node <NextFrame> with hex-string in attribute Value. I have no problem with collecting all this strings by parsing XML, so I eventually will have a whole piece of data to work with. But in frame 6 - there's a invalid XML (which I mentioned in my original post), and my XML-parser fails.

So this is my problem - why one of the parts of the response is invalid XML ?

BTW, after frame 6 - there's 2 more frames (parts of the response), again with valid XML, i.e. with node <NextFrame> and hex-string in attribute Value.

Profile picture for user Kurumi

Kurumi

4 years 9 months ago

Hi,

Hi,

There are several blocks and here is only the first one. You need to read all the blocks before you can parse the data. There is data only for 3 first rows and there should be 4 rows.

Also, there should be 713 bytes in this block, but there are only 712 bytes. You need to check what is causing that.

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