There are some options that relax the requirements, see the two ignoreunknown attributes here
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/r_gws_XmlSerializer_option_flags.html as well as attributes such as XMLOptional that may help you.
However if your question is more about the order, and you are asking as with an example like the following ...
IMPORT util
IMPORT xml
MAIN
DEFINE r RECORD
field1 STRING,
field2 STRING
END RECORD
DEFINE d1,d2 xml.DomDocument
-- JSON
INITIALIZE r TO NULL
CALL util.JSON.parse('{"field1":"value1","field2":"value2"}',r)
DISPLAY r.field1, r.field2
-- Swap order around, can still parse
INITIALIZE r TO NULL
CALL util.JSON.parse('{"field2":"value2","field1":"value1"}',r)
DISPLAY r.field1, r.field2
--XML
INITIALIZE r TO NULL
LET d1 = xml.DomDocument.create()
CALL d1.loadFromString("<root><field1>value1</field1><field2>value2</field2></root>")
CALL xml.Serializer.DomToVariable(d1.getDocumentElement(),r)
DISPLAY r.field1, r.field2
-- Swap order around, cannot parse
INITIALIZE r TO NULL
LET d2 = xml.DomDocument.create()
CALL d2.loadFromString("<root><field2>value2</field2><field1>value1</field1></root>")
CALL xml.Serializer.DomToVariable(d2.getDocumentElement(),r)
DISPLAY r.field1, r.field2
END MAIN
why you can swap the order for JSON and it will still parse, but if you swap the order for XML it won't parse.
I think the answer to this lies by using the XMLALL attribute
http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_gws_XML_attribute_XMLAll.htmlBy changing the above example to have
DEFINE r RECORD ATTRIBUTES(XMLAll)
then it runs which I suspect is what you are after.
Why do you need the option, and why does it not work by default, note that with a JSON string, the element name is unique, whilst the XML Node Name is not necessarily unique
Reuben