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
Use conn:merge{} to merge data into a database
Added by iNTERFACEWARE
Use iguana.isTest() to prevent code from running in the editor
Added by iNTERFACEWARE
Use iguana.isTest() to allow code to run in the editor but not in the live channel
Added by iNTERFACEWARE
Get the name or guid for the current channel by using iguana.channelName() or iguana.channelGuid()
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
Get the Iguana log (unique) message ID for the message currently being processed
Added by iNTERFACEWARE
Use iguana.setChannelStatus{} to set the channel dashboard channel status "light" and message
Added by iNTERFACEWARE
Set the timeout for the current script, must be set inside a function, usually main().
Added by iNTERFACEWARE
Use iguana.status() to return an XML summary of the local Iguana's runtime state
Added by iNTERFACEWARE
Use iguana.stopOnError(false) to prevent a channel from stopping when an error occurs
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.webInfo() to get web server and HTTP channel server configuration
Added by iNTERFACEWARE
Use iguana.workingDir() to get the current Iguana working directory, where config files etc. are stored
Added by iNTERFACEWARE
How to open a file and write (replace file content), or append data (keep file content)
Added by iNTERFACEWARE
Use os.fs.access() to check if a file exists, and to verify the permissions
Added by iNTERFACEWARE
Use os.fs.chmod() to set file permissions, using octal mode (symbolic mode does not work)
Added by iNTERFACEWARE
Use os.remove() to delete a file or directory, only an empty directory can be deleted
Added by iNTERFACEWARE
Use os.fs.rmdir() to delete an empty directory, if the directory is not empty an error is returned
Added by iNTERFACEWARE
Use os.fs.rename() to rename a file or directory, if the file or directory does not exist an error is returned