Set the value of an XML node
Verified
Added by iNTERFACEWARE
Use node.setInner() to set the value of an XML node, only works for XML nodes
Source Code
-- create sample XML node local x = [[ <patient id =""> <first-name>John</first-name> <last-name>Smith</last-name> </patient>]] xmlMsg = xml.parse(x) trace(xmlMsg) -- change the surname (last-name element) local node = xmlMsg.patient["last-name"]:setInner('Wilson') trace(xmlMsg) --> last-name change from "Smith" to Wilson" -- you probably don't want to do this local node = xmlMsg.patient:setInner('Oops I replaced all the patient data...') trace(xmlMsg) --> patient replaced with "Oops..."
Description
Use node.setInner() to set the value of an XML node, only works for XML nodes
Usage Details
Use node.setInner()
to set the value of any XML node. Warning: node.setInner()
this allows you replace a non-leaf node (unlike node.setNodeValue()
which raises and error), this means you can accidentally overwrite a node and sub-nodes, see the code for an example of how how (you don’t want) to do this.
Note: The node.setInner()
function only works for XML node trees.
How to use the snippet:
- Paste the code into your script
More Information
Added by iNTERFACEWARE
How to extract the tags from a string of html, using PCRE regex with string.rxmatch()
Added by iNTERFACEWARE
Find the position of the first instance of a string (pattern) within a string, returns the start and end indices
Added by iNTERFACEWARE
Using # or string.len() to find the length of a string, the result is the same
Added by iNTERFACEWARE
Use node.child() to return the node of the specified name, works for all node types
Added by iNTERFACEWARE
Use iguana.channelConfig{} to get configuration information for a channel, you can use either guid or channel name to specify the channel
Added by iNTERFACEWARE
Use os.fs.stat() to get statistics for a file or directory
Added by iNTERFACEWARE
Use iguana.status() to return an XML summary of the local Iguana's runtime state
Added by iNTERFACEWARE
Use iguana.webInfo() to get web server and HTTP channel server configuration
Added by iNTERFACEWARE
Use string.sub() to return part of a string, by specifying the start and end positions
Added by iNTERFACEWARE
Return the absolute value of a number, using math.abs()
Added by iNTERFACEWARE
Get the Iguana log (unique) message ID for the message currently being processed
Added by iNTERFACEWARE
Return the floor or ceiling for a number, using math.floor() or math.ceil()
Added by iNTERFACEWARE
Use iguana.version() to get the Iguana version number, can be useful for testing for a required/supported version
Added by iNTERFACEWARE
Use iguana.workingDir() to get the current Iguana working directory, where config files etc. are stored
Added by iNTERFACEWARE
Use node.nodeName() to get the name of a node, works for all node types
Added by iNTERFACEWARE
Get the name or guid for the current channel by using iguana.channelName() or iguana.channelGuid()
Added by iNTERFACEWARE
Use os.ts.difftime() to get the time in seconds between two time, this function allows for time zones and daylight saving
Added by iNTERFACEWARE
Use node.nodeType() to get the type of a node, works for all node types
Added by iNTERFACEWARE
Use node.nodeValue() to get the value of a leaf node, works for all node types