Get the value of a node
Verified
Added by iNTERFACEWARE
Use node.nodeValue() to get the value of a leaf node, works for all node types
Source Code
local Msg, Name = hl7.parse{vmd='example/demo.vmd', data=Data} -- get the value of a leaf node (surname) local name = Msg.PID[5][1][1][1]:nodeValue() --> "Surname" -- get the value of a non-leaf node (name) local name = Msg.PID[5][1][1]:nodeValue() --> ERROR: Branch nodes do not have values. -- best to check for leaf node first if Msg.PID[5][1][1]:isLeaf() then local name = Msg.PID[5][1][1]:nodeValue() --> nothing returned as not executed end
Description
Use node.nodeValue() to get the value of a leaf node, works for all node types
Usage Details
Use node.nodeValue()
to get the value of a leaf node.
Note: The node.nodeValue()
function works with all types of node trees.
How to use the snippet:
- Paste the code into your script
More Information
Added by iNTERFACEWARE
Use os.fs.chmod() to set file permissions, using octal mode (symbolic mode does not work)
Added by iNTERFACEWARE
Use node.setNodeValue() to set the value of a leaf node, works for all node types
Added by iNTERFACEWARE
Use node.setInner() to set the value of an XML node, only works for XML nodes
Added by iNTERFACEWARE
Use util.sleep() to pause code execution for the specified number of milliseconds
Added by iNTERFACEWARE
Use the string.split() function to split a string into parts separated by a specified delimiter
Added by iNTERFACEWARE
Use os.fs.access() to check if a file exists, and to verify the permissions
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).
Added by iNTERFACEWARE
Use conn:execute() to update a database table
Added by iNTERFACEWARE
How to encode and decode strings with AES, using filter.aes.enc{} and filter.aes.dec{}
Added by iNTERFACEWARE
How to encode and decode data as base 64, by using filter.base64.enc{} and filter.base64.dec{}
Added by iNTERFACEWARE
ftp commands to list, download, upload and rename files, the commands for ftps and sftp are similar
Added by iNTERFACEWARE
How to encode and decode strings with hex, using filter.hex.enc() and filter.hex.dec()
Added by iNTERFACEWARE
How to encode strings with html special characters, using filter.html.enc()
Added by iNTERFACEWARE
Using http.get{} http.post{} and http.put{} commands
Added by iNTERFACEWARE
Use the net.tcp module to send and receive using tcp sockets
Added by iNTERFACEWARE
Encode and decode strings for use in uri/url, using filter.uri.enc() and filter.uri.dec()
Added by iNTERFACEWARE
Encode and decode uuencoded strings or streams , using filter.uuencoding.enc() and filter.uuencoding.dec()
Added by iNTERFACEWARE
How to open a file and write (replace file content), or append data (keep file content)