Open topic with navigation

# LuaDocument Methods

This section describes the methods provided by the `LuaDocument` object. A `LuaDocument` allows you to access and modify the reference, metadata and content of a document.

If you have a `LuaDocument` object called `document` you can call its methods using the '`:`' operator. For example:

    document:addField(name, value)

Method | Description
--- | ---
addField | Creates a new field.
addSection | Add an empty section to the end of the document.
appendContent | Appends content to the existing content of the document.
copyField | Creates a new named field with the same value as an existing named field.
copyFieldNoOverwrite | Copies a field to a certain name but does not overwrite the existing value.
countField | Returns the number of fields with the name specified.
deleteField | Removes a field from the document.
getContent | Returns the document content.
getField | Returns the first field with a specified name.
getFieldNames | Returns all the field names for the document.
getFields | Returns all fields with the specified name.
getFieldValue | Gets a field value.
getFieldValues | Gets all values of a multi-valued field.
getNextSection | Gets the next section in a document, allowing you to perform find or add operations on every section.
getReference | Returns the document reference.
getSection | Returns a LuaDocument object with the specified section as the active section.
getSectionCount | Returns the number of sections in the document.
getValueByPath | Gets the value of the document field or sub field with the specified path.
getValuesByPath | Gets all values of a multi-value document field or sub field, with the specified path.
hasField | Checks whether the document has a named field.
insertXml | Inserts XML metadata into a document.
insertXmlWithoutRoot | Inserts XML metadata into a document.
renameField | Renames a field.
setContent | Sets the content for a document.
setFieldValue | Sets a field value.
setReference | Sets the document reference.
to_idx | Returns a string containing the document in IDX format.
to_json | Returns a string containing the document in JSON format.
to_xml | Returns a string containing the document in XML format.
writeStubIdx | Writes out a stub IDX document.
writeStubXml | Writes out a stub XML document.

© 2016 Hewlett Packard Enterprise Development LP | Send documentation feedback to HPE Close We welcome your comments! To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to AutonomyTPFeedback@hpe.com. Product: Topic Title: Help Topic: Feedback:

_HP_HTML5_bannerTitle.htm