02-28-2011 09:21 AM
Bonjour,
j'ai besoin de lire d'extraire des données sur des IO contenus dans un fichier XML dont le format est:
<?xml version="1.0" standalone='yes' ?> <Configuration_File xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation = "IB_CONF.xsd"> <IO_List> <IO_Car Name="8-Mc2a-1"> <IO_System Name="DriverDesk"> <IO IO_ID="0" IO_Name="Doorreleaseleftrelay" Data_Origin="Physical" Data_Type="Digital" Unit="" Description="Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="1" Material_Ressource="Targets/GRT_01/Hardware/Chassis/FPGA/RIO0/Input/Digital/Doorreleaseleftrelay" ID_GRT="1" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="1" IO_Name="MVBDoorreleaseleftrelay" Data_Origin="Bus" Data_Type="Digital" Unit="" Description="MVB_Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="0" Material_Ressource="Targets/GRT_01/Hardware/Chassis/FPGA/RIO0/Input/Digital/MVBDoorreleaseleftrelay" ID_GRT="1" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="4" IO_Name="rDoorreleaseleftrelay" Data_Origin="Physical" Data_Type="Digital" Unit="" Description="r:Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="3" Material_Ressource="Targets/GRT_01/Hardware/Chassis/FPGA/RIO0/Input/Digital/rDoorreleaseleftrelay" ID_GRT="1" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="5" IO_Name="MVBrDoorreleaseleftrelay" Data_Origin="Bus" Data_Type="Digital" Unit="" Description="MVB_r:Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="0" Material_Ressource="Targets/GRT_01/Hardware/Chassis/FPGA/RIO0/Input/Digital/MVBrDoorreleaseleftrelay" ID_GRT="1" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="8" IO_Name="Doorreleaserightrelay" Data_Origin="Physical" Data_Type="Digital" Unit="" Description="Door release right relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="1" Material_Ressource="Targets/GRT_01/Hardware/Chassis/FPGA/RIO1/Input/Digital/Doorreleaserightrelay" ID_GRT="1" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> </IO_System> </IO_Car> <IO_Car Name="8-Mc2a-8"> <IO_System Name="DriverDesk"> <IO IO_ID="2" IO_Name="Doorreleaseleftrelay" Data_Origin="Physical" Data_Type="Digital" Unit="" Description="Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="1" Material_Ressource="Targets/GRT_03/Hardware/Chassis/FPGA/RIO0/Input/Digital/Doorreleaseleftrelay" ID_GRT="3" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="3" IO_Name="MVBDoorreleaseleftrelay" Data_Origin="Bus" Data_Type="Digital" Unit="" Description="MVB_Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="0" Material_Ressource="Targets/GRT_03/Hardware/Chassis/FPGA/RIO0/Input/Digital/MVBDoorreleaseleftrelay" ID_GRT="3" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="6" IO_Name="rDoorreleaseleftrelay" Data_Origin="Physical" Data_Type="Digital" Unit="" Description="r:Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="3" Material_Ressource="Targets/GRT_03/Hardware/Chassis/FPGA/RIO0/Input/Digital/rDoorreleaseleftrelay" ID_GRT="3" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> <IO IO_ID="7" IO_Name="MVBrDoorreleaseleftrelay" Data_Origin="Bus" Data_Type="Digital" Unit="" Description="MVB_r:Door release left relay" Data_Format="U8" Default_Value="0" Max_Value="1" Min_Value="0" Direction="Input" Frequency="0" Material_Ressource="Targets/GRT_03/Hardware/Chassis/FPGA/RIO0/Input/Digital/MVBrDoorreleaseleftrelay" ID_GRT="3" Scaling_a="0" Scaling_b="0" Scaling_c="0" Scaling_d="0" Scaling_Offset="0"/> </IO_System> </IO_Car> </IO_List> </Configuration_File>
Mon problème est qu'il y a plus de 10 000 IO. Lorsque j'utilise les fonctions de parser XML native en LabView le temps de traitement est beaucoup trop long. Après de longue recherche, je n'ai trouvé que des outils payants (de type easyXML) alors que je ne peux pas me tourner vers une solution payante, ou des outils (comme GXML) qui ne correspondent pas à mon besoin.
De plus, il faudrait que je formate ces données en un tableau de cluster et je ne sais pas comment donner le nom de l'attribut au control formant le cluster. Je ne sais pas si c'est assez clair...
Auriez vous une solution?
Merci d'avance
03-01-2011 02:09 AM
Hello Choukette,
This part of the forum is in English, please use the French part here if you want to write in French.
You can use the XMLParser palette to get the value of your different nodes. This API is based on Xerces 2.7C++ and use DOM. What I can suggest you is to use the XPath to get the node references then navigate into it.
I have already used this API to read quite big XML files and I didn't notice any slow processing. Maybe you can post your code or an example.
03-01-2011 04:32 AM
Hi thanks for the answer.
I actually use the XMLParser and it takes 7 minutes to get 7000 IO.
I join my code and my XML file if you want to help me.
Thanks again.
03-01-2011 05:34 AM
I forgot to tell that my application should run on Pharlap.
03-02-2011 03:44 AM
Hello,
The XML Parser in LabVIEW is based on DOM so it doesn't work in LV RT unfortunately.
In addition there are a
couple of other tookits available that will work in LV RT and use their own
schema. In the case of GXML the source code is open so you can adjust the
schema to your needs. However, it is designed to store and load LabVIEW data
(clusters), so typically the XML structure will be similar to the data
structure in a LabVIEW cluster.
EasyXML: http://jkisoft.com/easyxml/
GXML: http://zone.ni.com/d...a/epd/p/id/6330
I'm not aware of a true generic XML parser that works in LV RT, though you could use the GXML parser code as a start and write one.