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
Convert a string to upper case with string.upper(), or lower case with string.lower()
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 node.remove() to delete an element from a table,
Added by iNTERFACEWARE
Use the net.tcp module to send and receive using tcp sockets
Added by iNTERFACEWARE
Create a generic ACK by using a script in an LLP Listener component
Added by iNTERFACEWARE
Use the string.split() function to split a string into parts separated by a specified delimiter
Added by iNTERFACEWARE
Use iguana.webInfo() to get web server and HTTP channel server configuration
Added by iNTERFACEWARE
Use table.insert() to insert an element into a table
Added by iNTERFACEWARE
How to encode and decode strings with AES, using filter.aes.enc{} and filter.aes.dec{}
Added by iNTERFACEWARE
Code to connect to commonly used databases (connecting to other databases is very similar).
Added by iNTERFACEWARE
Use string.sub() to return part of a string, by specifying the start and end positions
Added by iNTERFACEWARE
Use iguana.workingDir() to get the current Iguana working directory, where config files etc. are stored
Added by iNTERFACEWARE
Use util.sleep() to pause code execution for the specified number of milliseconds
Added by iNTERFACEWARE
How to encode and decode data as base 64, by using filter.base64.enc{} and filter.base64.dec{}
Added by iNTERFACEWARE
How to parse an HL7 message and create an HL7 output message
Added by iNTERFACEWARE
Use conn:query() to select data from a table in a database
Added by iNTERFACEWARE
How to open a file and write (replace file content), or append data (keep file content)
Added by iNTERFACEWARE
Use node.append() to append a node to an XML node tree
Added by iNTERFACEWARE
How to create and unzip a zip file containing multiple files and directories, using filter.zip.deflate() and filter.zip.inflate()
Added by iNTERFACEWARE
Use pcall() to trap errors by calling a function in protected mode (use to prevent a channel from stopping on "innocent" errors).