DOCUMENTS 5 - PortalScripting API
|
This class provides basic methods to parse or synthesize XML documents using the Document Object Model (DOM). More...
Public Member Functions | |
DOMParser () | |
The constructor actually takes no arguments. More... | |
DOMDocument | getDocument () |
This returns the root of the DOM tree after a successful call of parse(), otherwise null . | |
String | getLastError () |
This returns the text of the last occurred error. | |
Integer | parse (String xml, boolean fromFile) |
Parse an XML document, either from a String or from a local file. More... | |
Var | write (DOMNode node, String path, String encoding, boolean prettyPrint) |
Build an XML document from a DOM tree. More... | |
Public Attributes | |
Error Constants | |
In contrast to many other methods of the DOM API, the parse() method does not forward exceptions of the native parser to the calling script. It rather stores the error text in a buffer, which the script can read with getLastError(). The return value signals the type of the exception, which equals one of these constants. The constants are also properties of the constructor, so it is possible to read them in the style | |
Integer | ErrCatNone |
This constant with the value zero indicates "no error". | |
Integer | ErrCatEnv |
This constant represents errors detected by interface code outside the native parser. | |
Integer | ErrCatXML |
This constant represents a caught exception of the type "XMLException". | |
Integer | ErrCatSAX |
This constant represents a caught exception of the type "SAXException". | |
Integer | ErrCatDOM |
This constant represents a caught exception of the type "DOMException". | |
This class provides basic methods to parse or synthesize XML documents using the Document Object Model (DOM).
DOMParser::DOMParser | ( | ) |
The constructor actually takes no arguments.
Integer DOMParser::parse | ( | String | xml, |
boolean | fromFile | ||
) |
Parse an XML document, either from a String or from a local file.
xml | Either the XML itself or the path and file name of a local file |
fromFile | true to parse a local file, otherwise false . |
Var DOMParser::write | ( | DOMNode | node, |
String | path, | ||
String | encoding, | ||
boolean | prettyPrint | ||
) |
Build an XML document from a DOM tree.
node | The root node to build the document from. Though the interface accepts any DOMNode, only a DOMDocument should be passed. Otherwise the output may be a fragment which is not a valid XML. |
path | Optional path and filename to save the XML in the local file system. |
encoding | Optional encoding specification for the file. Only used when path is also specified. |
prettyPrint | Optional boolean value. |