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);  
xmlDoc.load("data.xml");  
if (xmlDoc.parseError.errorCode != 0)  
   WScript.Echo(xmlDoc.parseError.reason);  
else  
   WScript.Echo("Data loaded successfully");  

XML File (data.xml)

<?xml version='1.0'?>
<book-review>
   <book>
      <title>A Good Book</title>
      <author>The Good Writer</author>
      <publisher>The Publisher</publisher>
      <date>A Good Day</date>
      <Review>
          <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.
      </Review>
   </book>
   <book>
      <title>A Bad Book</title>
      <author>The Bad Writer</author>
      <publisher>The Publisher</publisher>
      <date>A Bad Day</date>
      <Review>
         <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.
      </Review>
   </book>
   <book>
      <title>A So-so Book</title>
      <author>The So-so Writer</author>
      <publisher>The Publisher</publisher>
      <date>A So-so Day</date>
      <Review>
         <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.
      </Review>
   </book>
</book-review>

DOM Security

Show: