XML Extension: Serialization_XmlToRecordList

XML Extension: Serialization_XmlToRecordList

  
XML Extension - received the following error when using Serialization_XmlToRecordList to convert xml to a recordlist.



Object reference not set to an instance of an object

OML attached (here)




Robert, have you put the ToObject() function around your XML variable when passing it to the serialisation function?

That is a tiny and often overlooked "must have"
Good comment and structure, by the way.
I don't see that very often :)
@Eric
thanks

"Robert, have you put the ToObject() function around your XML variable when passing it to the serialisation function?

That is a tiny and often overlooked "must have""

Yes, it is using ToObject(),.....(the oml is attached above)


......the Serialization_XmlToRecordList method keeps on complaining "Object reference not set to an instance of an object".


Sorry, I can't open it, it's a 5.1 version OML and we're using 5.0.
Hi Robert,

The XMLToRecordList and RecordToXML are a pure serialization / desserialization solution. You can only use in the XMLToRecordList with an XML that resulted from the execution of the RecordToXML action. The goal is for you to be able to store the status of a list or record (in a file, string, database, etc.) and then to be able to restore it back to your runtime list. The XML used in the XML extension is an internal XML representation defined in the extension.

This means that you should never have an XML coming from an external App and then use it directly as the input for the XMLToRecordList action - this would represent a direct dependency from your external app to the internal XML representation of the XML extension.

In order to have a robust API, a solution would be to strictly define  the XML structure, parse it with the XML manipulation actions in the XML extension and populate the resulting record with the parsing logic.

I see that the XML that you are inserting is "<xmlRegisterRequest><FirstName>testvalue</FirstName></xmlRegisterRequest>". This probably is not compatible with the XML To Record list reprsentation and that is why you are getting that error.

I made a test in which I exported two records to XML. One have FirstName="Daniel", the second has FirstName="Robert". The resulting XML was the one below:

<?xml version="1.0" encoding="utf-8"?>
<DBExport>
  <Entity name="xmlRegisterRequest">
    <Attribute>
      <Name>FirstName</Name>
      <Value>Daniel</Value>
    </Attribute>
  </Entity>
  <Entity name="xmlRegisterRequest">
    <Attribute>
      <Name>FirstName</Name>
      <Value>Robert</Value>
    </Attribute>
  </Entity>
</DBExport>

You can see the eSpace that does the export attached. To see it, just open the entry point Export.

Regards,

Daniel Lourenço
OutSystems
Hi Daniel
 
Thanks for the response, that makes sense.