/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// string wasStAX_SetNodeValue(string xmlStream, string node, string value) { list stream = llParseString2List(xmlStream, [""], ["<", ">", "/"]); integer size = llGetListLength(stream); list StAX = []; integer ptr = 0; integer set = 0; do { string current = llList2String(stream, ptr); string lookback = llList2String(stream, ptr-1); if(current != "/" && lookback == "<") { StAX += current; jump next_tag; } if(lookback == "/") { StAX = llDeleteSubList(StAX, -1, -1); jump next_tag; } if(current != ">" && current != "/" && current != "<") if(llList2String(StAX,llGetListLength(StAX)-1) == node) { if(!set) { stream = llListReplaceList(stream, (list)value, ptr, ptr); set = 1; jump next_tag; } stream = llListReplaceList(stream, (list)"", ptr, ptr); } @next_tag; } while(++ptr<size); if(llGetListLength(StAX) != 0) { llSay(DEBUG_CHANNEL, "The following tags may be unmatched: " + llDumpList2String(StAX, ",") + ". Please check your file."); } return llDumpList2String(stream, ""); }