SafeLoad Method
- Last UpdatedNov 06, 2025
- 1 minute read
Safely loads an XML document by turning off a number of XML processing options that open up security holes. The standard LoadXml method in XmlDocument class turns these options on which allows for XML attacks.
'Declaration
<ExtensionAttribute()>
Public Shared Sub SafeLoad( _
ByVal xmlDoc As XmlDocument, _
ByVal xml As String _
)
'Usage
Dim xmlDoc As XmlDocument
Dim xml As String
XmlExtensions.SafeLoad(xmlDoc, xml)
[Extension()]
public static void SafeLoad(
XmlDocument xmlDoc,
string xml
)
Parameters
- xmlDoc
- Holds the XmlDocument into which the XML will be loaded.
- xml
- Holds the XML to load in the document.