The parse_document_xml function parses an XML string or file into a document and returns a LuaDocument.
TIP: You can use this function if the string or file contains a single document. If you have an XML file that contains multiple documents you can use the function parse_document_xml(filename, handler [, params] ) instead.
parse_document_xml( input, file [, params ] )
| Argument | Description |
|---|---|
input
|
(string) The string or path to the file that contains the document in XML format. |
file
|
(boolean) Specifies whether the input argument is a path to a file. |
params
|
(table) A table of named parameters to configure parsing. The table maps parameter names (String) to parameter values. For information about the parameters that you can set, see the following table. |
| Named Parameter | Description |
|---|---|
content_paths
|
(string list, default DRECONTENT) The paths in the XML to the elements that contain document content. You can specify a list of paths. |
document_root_paths
|
(string list, default DOCUMENT) The paths in the XML to the elements that represent the root of a document. You can specify a list of paths. |
include_root_path
|
(boolean, default false) Specifies whether to include the document_root_paths node in the document metadata. The default value includes only children of the root node. |
reference_paths
|
(string list, default DREREFERENCE) The paths in the XML to elements that contain document references. Though you can specify a list of paths, there must be exactly one reference per document. |
The default values of the content_paths, document_root_path, and reference_paths arguments are suitable for processing XML documents written out using the CFS XmlWriter.
If you have a string named myXmlString that contains a document in XML format, you can obtain a LuaDocument object as follows:
local xmlParams = {
document_root_paths={"DOC"},
reference_paths={"REF"},
content_paths={"CONTENT","MORE_CONTENT"}
}
local myDocument = parse_document_xml(myXmlString, false, xmlParams)
(LuaDocument). A LuaDocument object that represents the document.
|
|