XmlDoc.LoadFile Shared Method

Loads and parses an XML text document from a file and returns the created XmlDoc DOM tree object.

XmlDoc.LoadFile(input_file, options)

Prerequisites

None

Parameters

input_file

A required String expression that contains the name of the XML data file to be read and parsed.

options

An optional numeric expression that specifies a bit mask of parsing-related options. The bits in the mask are defined as shown in the table below. If omitted, all option bits are assumed to be 0.

Remarks

This method creates a DOM tree in memory from a file containing XML text data. If it completes successfully, it returns the XmlDoc object for the DOM tree that contains all of the parsed data. The various XmlNode methods may then be used to access the data.

This method only throws an exception in the case of severe errors. Otherwise, it returns the XmlDoc object that includes any parsing errors. To check if the XML data has been properly parsed, you must verify that the xmldoc_object.ErrorCode method value is 0. If non-zero, check the error code and the xmldoc_object.Message values to determine why the parsing failed.

The options parameter is composed of bit flags that are defined in Table 19-120. Bits not shown in the table should be set to 0.

Table 19-120: options Parameter

Bit Mask Name Description

&H01

Recover

Attempt to continue parsing even if an error occurs.

&H20

Suppress errors

Suppress error reporting.

&H40

Suppress warnings

Suppress warning reporting.

&H100

Remove blank nodes

Remove nodes that contain only white space.

Examples

Dim doc As XmlDoc
doc = XmlDoc.LoadFile("/flash/test.xml") ' Parse the file
If doc.ErrorCode <> 0 Then ' Check for errors
Console.Writeline("Input error " & CStr(doc.ErrorCode) _
& ", " & doc.Message)
End If

See Also

XML Classes | XmlDoc New | xmldoc_object.ErrorCode | XmlDoc.LoadString | xmldoc_object.Message