Set the value of a node
Verified
Added by iNTERFACEWARE
Use node.setNodeValue() to set the value of a leaf node, works for all node types
Source Code
local Msg = hl7.message{vmd='demo.vmd', name='ADT'} -- NO BENEFIT: set the Time in the MSH segment Msg.MSH[7][1] = os.date('%Y%m%H%m') -- works: assigns value to the child node Msg.MSH[7][1]:setNodeValue(os.date('%Y%m%H%m')) -- works: set the node value -- BENEFIT: if you decide to use a variable local MsgTime = Msg.MSH[7][1] MsgTime:setNodeValue(os.date('%Y%m%H%m')) -- works: set the node value MsgTime = os.date('%Y%m%H%m') -- fails: assigns the date to the variable (try it)
Description
Use node.setNodeValue() to set the value of a leaf node, works for all node types
Usage Details
Use node.setNodeValue()
to set the value of a leaf node. Often assignment works instead (and is more succinct), however there are occasions when using node.setNodeValue()
is useful, for example if you place a node into a variable (see the sample code).
Note: The node.setNodeValue()
function works with all types of node trees.
How to use the snippet:
- Paste the code into your script
More Information
Added by iNTERFACEWARE
Create a generic ACK by using a script in an LLP Listener component
Added by iNTERFACEWARE
How to remove duplicate words from a string, using PCRE regex with string.rxsub()
Added by iNTERFACEWARE
How to extract the tags from a string of html, using PCRE regex with string.rxmatch()
Added by iNTERFACEWARE
How to convert an HL7 message to and from an XML representation, using chm.toXml{} and chm.fromXml{}
Added by iNTERFACEWARE
How to parse and serialize JSON, using json.parse{} and json.serialize{}
Added by iNTERFACEWARE
Return the floor or ceiling for a number, using math.floor() or math.ceil()
Added by iNTERFACEWARE
Return the absolute value of a number, using math.abs()
Added by iNTERFACEWARE
Encode and decode uuencoded strings or streams , using filter.uuencoding.enc() and filter.uuencoding.dec()
Added by iNTERFACEWARE
Encode and decode strings for use in uri/url, using filter.uri.enc() and filter.uri.dec()
Added by iNTERFACEWARE
How to encode strings with html special characters, using filter.html.enc()
Added by iNTERFACEWARE
How to encode and decode strings with hex, using filter.hex.enc() and filter.hex.dec()
Added by iNTERFACEWARE
How to create and unzip a bzip2 or gzip file, using filter.bzip2.deflate() and filter.bzip2.inflate() or gzip.deflate() and gzip.inflate()
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
How to encode and decode data as base 64, by using filter.base64.enc{} and filter.base64.dec{}
Added by iNTERFACEWARE
How to encode and decode strings with AES, using filter.aes.enc{} and filter.aes.dec{}
Added by iNTERFACEWARE
Use the net.tcp module to send and receive using tcp sockets
Added by iNTERFACEWARE
Using http.get{} http.post{} and http.put{} commands
Added by iNTERFACEWARE
ftp commands to list, download, upload and rename files, the commands for ftps and sftp are similar
Added by iNTERFACEWARE
Use node.setInner() to set the value of an XML node, only works for XML nodes