GetParseErrors

Description

Obtains a list of parsing errors detected during document parsing.

Syntax

pbdom_builder_name.GetParseErrors(ref string strErrorMessageArray[])

Argument

Description

pbdom_builder_name

The name of a PBDOM_BUILDER object

strErrorMessageArray

An unbounded array of strings, each of which will be filled with a formatted string containing a parse error.


Return value

Boolean.

Returns true if a list of parse errors has been retrieved and false otherwise. Also returns false if there are no parse errors.

Throws

EXCEPTION_INVALID_ARGUMENT -- The input string array is invalid. This can happen if it has not been initialized properly or is a null object reference.

EXCEPTION_MEMORY_ALLOCATION_FAILURE -- Insufficient memory was encountered while executing this method.

Examples

The code in this example attempts to create a PBDOM_DOCUMENT based on the following XML:

<!DOCTYPE root 
[
<!ELEMENT root ANY>
<!ELEMENT data (#PCDATA)> 
<!ENTITY text "Some Text">
]
>
<root><abc/><def/></root>

This XML is well formed but is not valid, because the element root contains two child elements abc and def that are not declared in the DOCTYPE. When GetParseErrors is called, it returns the value true, indicating that at least one parse error has occurred, and generates the following list of errors:

"1,103,Unknown element 'abc'"
"1,109,Unknown element 'def'"

The 1 in both error messages indicates that the error occurred in line 1 of the XML string, and the 103 and 109 indicate columns 103 and 109, respectively.

PBDOM_BUILDER pbdom_buildr
PBDOM_DOCUMENT pbdom_doc
long l = 0
string strXML = "<!DOCTYPE root [<!ELEMENT root ANY><!ELEMENT data (#PCDATA)> <!ENTITY text ~"Some Text~">]> <root><abc/><def/></root>"
string strParseErrors[]
BOOLEAN bRetTemp = FALSE

try
  pbdom_buildr = Create PBDOM_BUILDER
  pbdom_doc = pbdom_buildr.BuildFromString (strXML)
  bRetTemp = &
     pbdom_buildr.GetParseErrors(strParseErrors)
  
  if bRetTemp = true then
    for l = 1 to UpperBound(strParseErrors)
       MessageBox ("Parse Error", strParseErrors[l])
    next
  end if
catch (PBDOM_EXCEPTION pbdom_except)
  MessageBox ("PBDOM_EXCEPTION", &
     pbdom_except.GetMessage())
end try

Usage

This method retrieves a list of errors detected during the last parse operation performed by this PBDOM_BUILDER. Each string in the array has the following format:

[Line Number],[Column Number],[Error Message]

where Line Number and Column Number indicate the line number and column number in the XML document where the error was encountered. Error Message is the parse error message.