xmlfile
Retrieves data from XML files.
Command properties
| Property | Description |
|---|---|
| Command type | Driver query |
| Required permission | Local file read access |
| License usage | Counted |
| Parallel execution | Not supported |
| Distributed execution | Not 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 thecharsetoption. 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
| Field | Type | Description |
|---|---|---|
| (XML element) | auto | Fields mapped from XML element names and values |
| _file | string | Original file name |
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 13100 | - | No file path was specified |
| 13102 | - | The file does not exist or cannot be read |
| 13101 | - | The parent directory does not exist or cannot be read |
| 13103 | - | The XPath expression cannot be compiled |
| 13104 | - | The XML file is 10 MB or larger |
| 13105 | - | Access 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
-
Query an entire XML file
xmlfile /opt/logpresso/data/config.xmlRetrieves all data from the XML file.
-
Select specific nodes using XPath
xmlfile xpath="//item" /opt/logpresso/data/catalog.xmlUses an XPath expression to retrieve all
itemnodes.