/* * SPL - The SPL Programming Language * Copyright (C) 2004, 2005 Clifford Wolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * example54.spl: simple example for modifying XML objects */ // SKIP_IF_NO_LIBXML2 // SKIP_IF_NO_REGEX load "xml"; var xmldoc = xml_parse(<:> : : : ... : ... : ... : ... : ... : ... : : ); foreach[] i (xmldoc["//@year"].nodes) xmldoc[i] =~ s/2004/2005/; xmldoc["//*[string(@year) = '1980']"].xml = "foo clifford's birthyear is 1980 bar"; xmldoc["//*[string(@year) = '2060']"].innerxml = "this record is in the future!"; xmldoc["//*[string(@year) = '1960']"].innerxml = xmldoc["//*[string(@year) = '2060']"].innerxml =~ s/future/past/R; delete xmldoc["//delme"]; xmldoc["//container"].add_xml_top = "MID"; xmldoc["//container"].add_xml_bottom = "BOT"; xmldoc["//container"].add_xml_top = "TOP"; xmldoc["//container"].add_xml_before = "BEF"; xmldoc["//container"].add_xml_after = "AFT"; debug xml_dump(xmldoc);