MaxXMLSize Sample


This example illustrates how to use the MaxXMLSize property to limit the size of the XML data that can be loaded in a DOM instance. The value of this property is specified in kilobytes. The default value is 0. A value of 0 means "unlimited".

An error is reported if you try to load XML data that is larger than the size that is defined by this property.

When you try to use the following JScript code to load data.xml, you receive the following error message:

Operation aborted: MaxXMLSize constraint violated.  

You receive the error message because data.xml is larger than 1 KB.

JScript File (testdata.js)

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");  
xmlDoc.async = false;  
xmlDoc.resolveExternals = true;     
//MaxXMLSize is defined as 1KB  
xmlDoc.setProperty("MaxXMLSize", 1);  
if (xmlDoc.parseError.errorCode != 0)  
   WScript.Echo("Data loaded successfully");  

XML File (data.xml)

<?xml version='1.0'?>
      <title>A Good Book</title>
      <author>The Good Writer</author>
      <publisher>The Publisher</publisher>
      <date>A Good Day</date>
          <title>A Good Book</title> by <author>The Good Writer</author>, 
          published by <publisher>The Publisher</publisher> on <date>A 
          Good Day</date>, is indeed a good book.
      <title>A Bad Book</title>
      <author>The Bad Writer</author>
      <publisher>The Publisher</publisher>
      <date>A Bad Day</date>
         <title>A Bad Book</title> by <author>The Bad Writer</author>, 
         published by <publisher>The Publisher</publisher> on <date>A Bad 
         Day</date>, is indeed a bad book.
      <title>A So-so Book</title>
      <author>The So-so Writer</author>
      <publisher>The Publisher</publisher>
      <date>A So-so Day</date>
         <title>A So-so Book</title> by <author>The So-so Writer</author>, 
         published by <publisher>The Publisher</publisher> on 
         <date>A So-so Day</date>, is indeed a so-so book.

DOM Security