Skip to content

Commit 9c12685

Browse files
Christian Unterbergeroroulet
authored andcommitted
Fix invalid xml serialization of DateTime value
Serialization emitted wrong string for the XML dateTime type Wrong: <uax:DateTime>2020-01-31 12:00:00</uax:DateTime> Correct: <uax:DateTime>2020-01-31T12:00:00</uax:DateTime> Notice the missing T seperator in the text representation of the value attribute. In XML the parser expects a string according to this format. https://www.w3.org/TR/xmlschema-2/#dateTime Fixes issue #1343
1 parent 3012acf commit 9c12685

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

opcua/common/xmlexporter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ def _val_to_etree(self, el, dtype, val):
377377
val = b""
378378
data = base64.b64encode(val)
379379
el.text = data.decode("utf-8")
380+
elif dtype == ua.NodeId(ua.ObjectIds.DateTime):
381+
el.text = val.isoformat()
380382
elif not hasattr(val, "ua_types"):
381383
if isinstance(val, bytes):
382384
# FIXME: should we also encode this (localized text I guess) using base64??

0 commit comments

Comments
 (0)