# 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. E.g. the baudrate and internal buffer of Serial, packet behaviour of Ethernet, or paging of SD cards. If performance is low one should do testruns 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 include a call to **XML.flush()** at the end of the XML generation. This will flush the last bytes in the internal buffer. ## Interface Constructor - **XMLWriter(stream, bufsize);** Constructor defines the stream and the buffersize to optimize performance vs memory usage. Functions for manual layout control - **setIndentSize(size = 2);** preferred a multiple of 2; - **incrIndent()** - **decrIndent()** - **indent();** - **raw(str)** inject any string General settings - **setConfig(cfg)** used to show/strip comment, indent, newLine. use **setConfig(0);** to minimize the output - **newLine(n)** add a number of newlines to the output, default = 1 ---- Functions - **reset()** resets internal state, to be called before new XML is written - **Header()** injects standard XML header string, must be first line - **comment(text, multiline)** \