PBDOM_BUILDER:
GetParseErrors method
Description
Obtains
a list of parsing errors detected during document parsing.
Syntax
1 |
<span>pbdom_builder_name.</span>GetParseErrors(ref string <span>strErrorMessageArray</span>[]) |
Argument |
Description |
---|---|
pbdom_builder_name |
The name of a PBDOM_BUILDER |
strErrorMessageArray |
An unbounded array of strings, each of |
Return Values
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
initialised 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:
1 |
<!DOCTYPE root <br>[<br><!ELEMENT root ANY><br><!ELEMENT data (#PCDATA)> <br><!ENTITY text "Some Text"><br>]<br>><br><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 |
"1,103,Unknown element 'abc'"<br>"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.
1 |
PBDOM_BUILDER pbdom_buildr<br>PBDOM_DOCUMENT pbdom_doc<br>long l = 0<br>string strXML = "<!DOCTYPE root [<!ELEMENT root ANY><!ELEMENT data (#PCDATA)> <!ENTITY text ~"Some Text~">]> <root><abc/><def/></root>"<br>string strParseErrors[]<br>BOOLEAN bRetTemp = FALSE<br> <br>try<br>  pbdom_buildr = Create PBDOM_BUILDER<br>  pbdom_doc = pbdom_buildr.BuildFromString (strXML)<br>  bRetTemp = &<br>     pbdom_buildr.GetParseErrors(strParseErrors)<br>  <br>  if bRetTemp = true then<br>    for l = 1 to UpperBound(strParseErrors)<br>       MessageBox ("Parse Error", strParseErrors[l])<br>    next<br>  end if<br>catch (PBDOM_EXCEPTION pbdom_except)<br>  MessageBox ("PBDOM_EXCEPTION", &<br>     pbdom_except.GetMessage())<br>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:
1 |
[<span>Line Number</span>],[<span>Column Number</span>],[<span>Error Message</span>] |
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.