Go Down

Topic: simple XMLwriter library for Arduino (Read 18348 times) previous topic - next topic


Really want to use this Library, but how can I stream the output to String?

Thank you!  ;)
..:: <3 I love this beautiful world <3 ::..


// copy of github issue

You can use this class

Code: (experimental) [Select]
//    FILE: PrintString.h
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.00
// PURPOSE: Class that captures prints into a String
//    DATE: 2017-12-07
//     URL:
// Released to the public domain

#ifndef PrintString_h
#define PrintString_h

#include "Arduino.h"
#include "Print.h"


class PrintString: public Print
  PrintString() {};
  size_t write(uint8_t c)
    buffer += (char)c;
    return 1;
  void clear()
    buffer = "";
  String getString() { return buffer; }

  String buffer;
// -- END OF FILE --

and use like this

Code: [Select]
//    FILE: printString.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.0.1
// PURPOSE: demo experimental

#include "PrintString.h"

#include "XMLWriter.h"

PrintString ps;
XMLWriter XML(&ps);
char buffer[24];

void setup()

  ps.println("Hello World");
  ps.println(3.14159265, 4);

  ps.println(3.14159265, 4);
  ps.println("Hello World");


  XML.comment("Weather in Nebraska");
  XML.writeNode("Date", "20131106");
  XML.writeNode("Time", "11:42");
  XML.writeNode("Temp", "23.4");
  XML.writeNode("Humi", "50%");
  XML.writeNode("Rain", "10mm");
  XML.writeNode("Sun", "40");


void loop()
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Dear robtillaart ;

thank you for your contribuation about the xmlwriter ...

but i have some questions

can i insert the ehealth sensors readings coming from ehealth shield compalete kit .. connected to arduino -- and the arduino connected with the computer through USB cable..

can i get the sensors data (such as Blood pressure and Spo2)
and store the readings in XML file .. using XMLWriter... ?? and how ??

best regards
Late answer, don't know it is relevant

Yes you can store these in an XML in a very similar way as in the examples of the library.
If you still need help, post your code you have- and yes I do expect some serious code after a year :)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


Pictures of code are not next to useless. They are so far less than useless.

Post your code AS TEXT.

The XML you appear to get from the server is NOT well formed. You should fix that issue FIRST.
The art of getting good answers lies in asking good questions.


Jun 04, 2018, 03:16 am Last Edit: Jun 04, 2018, 03:34 am by dito
how to receive xml request from x100c fingerprint with ethershield,
example using pascal:

i try thi code :
Code: [Select]

#include <SPI.h>
#include <Ethernet.h>
#include <XMLWriter.h>

XMLWriter XML(&Serial);

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(10,45,1,7);  // IP Fingerprint x100c
IPAddress ip(10,45,1,6);      // IP Arduino

EthernetClient client;

void setup() {
  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  Ethernet.begin(mac, ip);
  // give the Ethernet shield a second to initialize:
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    XML.writeNode("ArfComkey xsi:type=\"xsd:integer\"","0");
    XML.writeNode("PIN xsi:type=\"xsd:integer\"","ALL");
    String method = "GET /iWsService\r\n";
      method += "HTTP/1.1\r\n";
      method += "Host:\r\n";
      method += "Connection: Close\r\n";
      method += "<GetAttLog><ArgComKey xsi:type=\"xsd:integer\">0</ArgComKey><Arg><PIN xsi:type=\"xsd:integer\">All</PIN></Arg></GetAttLog>";
    String content = String (method);
    // Make a HTTP request:
    client.println("GET /iWsService HTTP/1.1");
    client.println("content-type: text/xml");
    client.println("content-length: 128");
    client.println("<GetAttLog><ArgComKey xsi:type=\"xsd:integer\">0</ArgComKey><Arg><PIN xsi:type=\"xsd:integer\">All</PIN></Arg></GetAttLog>");

  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");


void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  if (client.available()) {
    char c = client.read();
  // if the server's disconnected, stop the client:
  if (!client.connected()) {

    // do nothing forevermore:
    while (true);

im stuck parse and execute xml comand from finger print,
and im try but not show .

and show my serial monitor..
Code: [Select]

<?xml version="1.0" encoding="UTF-8">
  <ArfComkey xsi:type="xsd:integer">0</ArfComkey xsi:t>
    <PIN xsi:type="xsd:integer">ALL</PIN xsi:type="x>
GET /iWsService
Connection: Close
<GetAttLog><ArgComKey xsi:type="xsd:integer">0</ArgComKey><Arg><PIN xsi:type="xsd:integer">All</PIN></Arg></GetAttLog>
HTTP/1.0 200 OK
Server: ZK Web Server
Pragma: no-cache
Cache-control: no-cache
Content-Type: text/xml
Connection: close


Go Up