Name

toString()

Class

XML

Description

Takes an XML object and converts it to a String, using default formatting rules (includes an XML declaration, line breaks, and two spaces for indents). These are the same formatting rules used by println() when printing an XML object. This method produces the same results as using format(2).

Examples

  • String data = "<mammals><animal>Goat</animal></mammals>";
    
    void setup() {
      XML xml = parseXML(data);
      
      //Format with line breaks, XML declaration, and 2-space indentation
      String s = xml.toString();
      println(s);
    }
    
    // Sketch prints:
    //<?xml version="1.0" encoding="UTF-8"?>
    //<mammals>
    //  <animal>Goat</animal>
    //</mammals>
    

Syntax

  • .toString()

Return

  • String