Parses an XML text document from a String and returns the created XmlDoc DOM tree object.
… XmlDoc.LoadString(input_string, options)
Prerequisites
None
Parameters
input_file
A required String expression that contains the XML data to be parsed. The string may be very long.
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 the XML text data contained in a String. 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 an 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-121. Bits not shown in the table should be set to 0.
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
Dim instr As String = ""
Dim line As String
' Read the input file
Dim inf As New StreamReader("/flash/test.xml")
While inf.Peek() >=0 ' Check if end-of-file
line = inf.Readline()
instr &= line
End While
inf.Close()
doc = XmlDoc.LoadString(instr) ' Parse the input
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.LoadFile | xmldoc_object.Message