Platforms to show: All Mac Windows Linux Cross-Platform

Back to XMLParserMBS class.

XMLParserMBS.abort

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Abort the loading of the document that is currently being loaded by the XMLParserMBS.

If the XMLParserMBS is currently not busy, a call to this method does nothing.
invoking this method will remove the installed filter

XMLParserMBS.Constructor(Asynchronous as Boolean = false, schemaType as string = "")

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Create a new XMLParserMBS.

The newly constructed parser may then be configured by means of its XMLConfigurationMBS object, and used to parse documents by means of its parse method.

async: The mode argument is either synchronous or asynchronous, if async is true then the XMLParserMBS that is created will operate in synchronous mode, if async is false then the XMLParserMBS that is created will operate in asynchronous mode.

schemaType: An absolute URI representing the type of the schema language used during the load of a XMLDocumentMBS using the newly created XMLParserMBS. Note that no lexical checking is done on the absolute URI. In order to create a XMLParserMBS for any kind of schema types (i.e. the XMLParserMBS will be free to use any schema found), use the value "".

Note: For W3C XML Schema [XML Schema Part 1], applications must use the value "http://www.w3.org/2001/XMLSchema". For XML DTD [XML 1.0], applications must use the value "http://www.w3.org/TR/REC-xml". Other Schema languages are outside the scope of the W3C and therefore should recommend an absolute URI in order to use this method.

XMLParserMBS.parse(inputSource as XMLInputMBS) as XMLDocumentMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Parse an XML document from a resource identified by a XMLInputMBS.
Example

Dim xmlText As String = "<test id=""123""><f>1</f><f>2</f><f>3</f><f>4</f></test>"

Dim Input As New XMLInputMBS
Input.Encoding = "UTF-8"
Input.InputString = xmlText

Dim parser As New XMLParserMBS
Dim doc As XMLDocumentMBS = parser.parse(Input)

// inspect document in debugger
MessageBox doc.toString

The parser owns the returned XMLDocumentMBS. It will be deleted when the parser is released.

source: The XMLInputMBS from which the source of the document is to be read.

If the XMLParserMBS is a synchronous XMLParserMBS the newly created and populated XMLDocumentMBS is returned.
If the XMLParserMBS is asynchronous then nil is returned since the document object may not yet be constructed when this method returns.

XMLParserMBS.parseFile(file as FolderItem) as XMLDocumentMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Parses a file.
Example

Dim p As New XMLParserMBS
Dim f As FolderItem = SpecialFolder.Desktop.Child("test.xml")

Dim doc As XMLDocumentMBS = p.parseFile(f)

// inspect document in debugger
MessageBox doc.NodeName

XMLParserMBS.parseURI(URI as String) as XMLDocumentMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Parse an XML document from a location identified by a URI reference [IETF RFC 2396].

If the URI contains a fragment identifier (see section 4.1 in [IETF RFC 2396]), the behavior is not defined by this specification, future versions of this specification may define the behavior.

The parser owns the returned XMLDocumentMBS. It will be deleted when the parser is released.

uri: The location of the XML document to be read (in Unicode)

If the XMLParserMBS is a synchronous XMLParserMBS the newly created and populated XMLDocumentMBS is returned.
If the XMLParserMBS is asynchronous then nil is returned since the document object is not yet parsed when this method returns.

XMLParserMBS.parseWithContext(inputSource as XMLInputMBS, contextNode as XMLNodeMBS, Action as Integer) as XMLNodeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Parse an XML fragment from a resource identified by a XMLInputMBS and insert the content into an existing document at the position specified with the context and action arguments.
Example

Dim xmlText As String = "<test id=""123""><f>1</f><f>2</f><f>3</f><f>4</f></test>"

Dim Input As New XMLInputMBS
Input.Encoding = "UTF-8"
Input.InputString = xmlText

Dim parser As New XMLParserMBS

Dim doc As New XMLDocumentMBS("", "MyDocument")

// load new test node into the MyDocument
Dim newNode As XMLNodeMBS = parser.parseWithContext(Input, doc.DocumentElement, parser.ActionAppendAsChildren)

// inspect document in debugger
MessageBox doc.toString

When parsing the input stream, the context node (or its parent, depending on where the result will be inserted) is used for resolving unbound namespace prefixes. The context node's ownerDocument node (or the node itself if the node of type document) is used to resolve default attributes and entity references. As the new data is inserted into the document, at least one mutation event is fired per new immediate child or sibling of the context node. If the context node is a XMLDocumentMBS node and the action is ActionReplaceChildren, then the document that is passed as the context node will be changed such that its xmlEncoding, documentURI, xmlVersion, inputEncoding, xmlStandalone, and all other such attributes are set to what they would be set to if the input source was parsed using parse(). This method is always synchronous, even if the XMLParserMBS is asynchronous (when Async() returns true). If an error occurs while parsing, the caller is notified through the ErrorHandler instance associated with the "error-handler" parameter of the XMLConfigurationMBS. When calling parseWithContext, the values of the following configuration parameters will be ignored and their default values will always be used instead: "validate", "validate-if-schema" "element-content-whitespace". Other parameters will be treated normally, and the parser is expected to call the XMLParserMBSFilter just as if a whole document was parsed.

source: The XMLInputMBS from which the source document is to be read. The source document must be an XML fragment, i.e. anything except a complete XML document (except in the case where the context node of type DOCUMENT_NODE, and the action is ActionReplaceChildren), a DOCTYPE (internal subset), entity declaration(s), notation declaration(s), or XML or text declaration(s).

contextNode: The node that is used as the context for the data that is being parsed. This node must be a XMLDocumentMBS node, a XMLDocumentFragmentMBS node, or a node of a type that is allowed as a child of an XMLElementMBS node, e.g. it cannot be an XMLAttributeMBS node.

action: This parameter describes which action should be taken between the new set of nodes being inserted and the existing children of the context node. The set of possible actions is defined in action constants.

Return the node that is the result of the parse operation. If the result is more than one top-level node, the first one is returned.

XMLParserMBS.resetCachedGrammarPool

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Clear the cached grammar pool.

XMLParserMBS.resetDocumentPool

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Reset the documents vector pool and release all the associated memory back to the system.

When parsing a document using a DOM parser, all memory allocated for a DOM tree is associated to the DOM document.

If you do multiple parse using the same DOM parser instance, then multiple DOM documents will be generated and saved in a vector pool. All these documents (and thus all the allocated memory) won't be deleted until the parser instance is destroyed.

If you don't need these DOM documents anymore and don't want to destroy the DOM parser instance at this moment, then you can call this method to reset the document vector pool and release all the allocated memory back to the system.

It is an error to call this method if you are in the middle of a parse (e.g. in the mid of a progressive parse).

XMLParserMBS.URIText(ID as Integer) as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
method XML MBS XML Plugin 22.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the string corresponding to a URI id from the URI string pool.

ID: id of the string in the URI string pool.

Returns the URI string corresponding to the URI id.

The items on this page are in the following plugins: MBS XML Plugin.


The biggest plugin in space...