Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robtillaart/xmlwriter
Arduino Library to create simple XML (messages, files, print, ...)
https://github.com/robtillaart/xmlwriter
arduino writer xml
Last synced: 3 months ago
JSON representation
Arduino Library to create simple XML (messages, files, print, ...)
- Host: GitHub
- URL: https://github.com/robtillaart/xmlwriter
- Owner: RobTillaart
- License: mit
- Created: 2020-04-25T14:40:56.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T09:15:02.000Z (10 months ago)
- Last Synced: 2024-08-07T18:27:15.624Z (6 months ago)
- Topics: arduino, writer, xml
- Language: C++
- Homepage:
- Size: 65.4 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![Arduino CI](https://github.com/RobTillaart/XMLWriter/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/XMLWriter/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/XMLWriter/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/XMLWriter/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/XMLWriter/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/XMLWriter.svg)](https://github.com/RobTillaart/XMLWriter/issues)[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/XMLWriter/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/XMLWriter.svg?maxAge=3600)](https://github.com/RobTillaart/XMLWriter/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/XMLWriter.svg)](https://registry.platformio.org/libraries/robtillaart/XMLWriter)# XMLWriter
Arduino Library to create simple XML (messages, files, print, ...).
## Description
The XMLWriter class supports generating XML files and send these over a stream
like Ethernet SD.File or Serial.When instantiating an XMLWriter one can define the internal buffer size.
A bigger buffer will make the output faster, especially for Ethernet and SD.File.
The buffer size should be at least 2 bytes and max 250.
How much faster depends on the properties of the stream and the platform used.
E.g. the baud rate and internal buffer of Serial, packet behaviour of Ethernet,
or paging of SD cards.
If performance is low one should do test runs with different sizes for the buffer
and choose one that is appropriate.Indicative sizes based upon the examples.
Run your tests to find your application optimum.| STREAM | SIZE |
|:-----------|:-----------|
| Ethernet | 20-30 |
| Serial | 5 |
| SD File | 10-16 |**IMPORTANT:** When using buffering you should always call **XML.flush()**
at the end of the XML generation. This will flush the last bytes in the internal buffer into the output stream.## Interface
```cpp
#include "XMLWriter.h"
```### Constructor
- **XMLWriter(Print\* stream = &Serial, uint8_t bufferSize = 10)** Constructor defines the stream and the buffer size
to optimize performance vs memory usage.
Note the default bufferSize of 10 can be optimized.
See table in description above.### Functions for manual layout control
- **void setIndentSize(uint8_t size = 2)** preferred a multiple of 2; no limit.
- **uint8_t getIndentSize()** returns set indent.
- **void incrIndent()** increments indent by 2 spaces.
- **void decrIndent()** decrements indent by 2 spaces.
- **void indent()** manually indent output.
- **void raw(char\* str)** inject any string.### General settings
- **void setConfig(uint8_t config)** used to show/strip comment, indent, newLine.
use **setConfig(0);** to minimize the output.
- **void newLine(uint8_t n)** add a number of newlines to the output, default = 1.### Functions
- **void header()** injects standard XML header string, must be first line.
- **void reset()** resets internal state, to be called before new XML is written.
- **void comment(char\* text, bool multiLine = false)** \