I've seen people complaining a few times in the forums that LabVIEW's inbuilt XML functions aren't very user friendly etc. Well here is an example of what can be done with them.
The methods used in extracting data from an XML document are what new users may find educational.
My main usage for this vi is to extract UDS (ISO 14229 / ISO 15765) diagnostic information for use in automated testing. It may need some tweaking for other protocols.
If you want to use that information in a test application it can be quite tricky to extract.
There can be some very complex structures defined for datatypes etc.
This example demonstrates how you can use inbuilt LabVIEW XML functions to read all sorts of information no matter how deeply it is buried in an XML document.
This VI (and subvis) read a complex (and potentially quite large) XML file and output it's useful contents in a format that can be used by your software.
The main vi is a state machine that traverses through the relevant xml nodes creating an array of relevant nodes which are then used by subvis to extract the desired data.
The most complex subvi is the one that extracts DIDs (Data by Identifier) and information on how to extract signals from the data they return.
DIDs (can) contain complex structures with 'c' type UNIONs and STRUCTs.
The vi grabs all the subsignals defined for a DID and builds an array of signal references.
When reading a DID an array of bytes is returned. Data is extracted from the byte array according to the DID structure definition. Each STRUCT can contain STRUCTs UNIONs DATAOBJects and something called a GAPDATAOBJect.
The signal references created by this vi treat the byte array as one continuous bitstream.
Therefore each DID contains an array of signals. Each signal has a name, a startbit and a length.
It will then extract the DIDs, Datatypes and Diagnostic Trouble codes from the .cdd database file.
The results displayed on the front panel may not look all that exciting unless you've tried to do automated diagnostics on CAN.
Main Block Diagram:
Any suggestions on improvement are welcome.