DTD reference in source XML document causes errors when calling FromXml - 'For security reasons dtd is prohibited in this xml document'

If your source XML document contains a DOCTYPE reference to an external DTD like in this example.
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE people_list SYSTEM "example.dtd">
<people_list>
  ...
 
Then you may get the following error when a FromXml method is called.
"For security reasons dtd is prohibited in this xml document"
 
This is because by default the .Net XML parser will not process DTD documents (for security reasons), to change the behavior to either ignore them or process them you must create your own XmlSerializationContext and set the DtdProcessing property accordingly
 
GeneratedDataBindingClass xmlObj = new GeneratedDataBindingClass();
LiquidTechnologies.Runtime.Net40.XmlSerializationContext ctx = new LiquidTechnologies.Runtime.Net40.XmlSerializationContext();

ctx.DtdProcessing = LiquidTechnologies.Runtime.Net40.XmlSerializationContext.DtdProcessingType.Ignore;
xmlObj.FromXmlFile(fullName, ctx);
 
 
This applies to XML Data Binding for C# Liquid XML Studio 11.0.13 and greater.

Add Feedback