xmlfile

Retrieves data from XML files.

Command properties

PropertyDescription
Command typeDriver query
Required permissionLocal file read access
License usageCounted
Parallel executionNot supported
Distributed executionNot supported

Syntax

xmlfile [cs=STR] [xpath=STR] PATH

Options

cs=STR
Character encoding of the XML file (default: utf-8). Can also be specified using the charset option.
xpath=STR
XPath expression for selecting XML nodes. If not specified, the entire XML is returned as a single record.

Target

PATH
XML file path. You can use a wildcard (*).

Output fields

FieldTypeDescription
(XML element)autoFields mapped from XML element names and values
_filestringOriginal file name

Error codes

Parsing errors
Error codeMessageDescription
13100missing path of xmlfileNo file path was specified
13102invalid xmlfile pathThe file does not exist or cannot be read
13101invalid directory path of xmlfileThe parent directory does not exist or cannot be read
13103cannot compile xpath of xmlfile: [error]The XPath expression cannot be compiled
13104too big xml file: [size]MB >= 10MBThe XML file is 10 MB or larger
13105access-denied-to-fileAccess to the file was denied

Description

The xmlfile command parses XML files and returns each element as a record. Use the xpath option to select and query specific nodes.

XML files of 10 MB or larger cannot be processed. When multiple files are specified using a wildcard, files that are 10 MB or larger or that cause an error are skipped with a warning log.

Files that contain a BOM (Byte Order Mark) are automatically recognized.

Examples

  1. Query an entire XML file

    xmlfile /opt/logpresso/data/config.xml
    

    Retrieves all data from the XML file.

  2. Select specific nodes using XPath

    xmlfile xpath="//item" /opt/logpresso/data/catalog.xml
    

    Uses an XPath expression to retrieve all item nodes.