Name |
saveXML()保存XML对象 |
||||||||
Examples |
// The following short XML file called “mammals.xml” is parsed // in the code below. It must be in the project’s “data” folder. // // <?xml version=”1.0″?> // <mammals> // <animal id=”0″ species=”Capra hircus”>Goat</animal> // <animal id=”1″ species=”Panthera pardus”>Leopard</animal> // <animal id=”2″ species=”Equus zebra”>Zebra</animal> // </mammals>
XML xml;
void setup() { xml = loadXML(“mammals.xml”); XML firstChild = xml.getChild(“animal”); xml.removeChild(firstChild); saveXML(xml, “subset.xml”); }
// Sketch saves the following to a file called “subset.xml”: // <?xml version=”1.0″?> // <mammals> // <animal id=”1″ species=”Panthera pardus”>Leopard</animal> // <animal id=”2″ species=”Equus zebra”>Zebra</animal> // </mammals> |
||||||||
Description |
Writes the contents of an XML object to a file. By default, this file is saved to the sketch’s folder. This folder is opened by selecting “Show Sketch Folder” from the “Sketch” menu. Alternatively, the file can be saved to any location on the computer by using an absolute path (something that starts with / on Unix and Linux, or a drive letter on Windows). All files loaded and saved by the Processing API use UTF-8 encoding. 将 xml 对象的内容写入文件。默认情况下, 此文件保存到草绘的文件夹中。通过从 “草绘” 菜单中选择 “显示草图文件夹” 打开此文件夹。
或者, 该文件可以通过使用绝对路径 (在 unix 和 linux 上启动的东西, 或 windows 上的驱动器号) 保存到计算机上的任何位置。
处理 api 加载和保存的所有文件都使用 UTF-8 编码。 |
||||||||
Syntax |
saveXML(xml, filename) |
||||||||
Parameters |
|
||||||||
Returns |
boolean |
||||||||
Related |
XML |
- 本文固定链接: http://iprocessing.cn/2017/08/02/savexml保存xml对象/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表