LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I read the ID's of a list from a xml file?

Solved!
Go to solution

The xml file has the following content:

        <Art_list>

<Art1>1000</Art1>

<Art2>1010</Art2>

<Art3>1020</Art3>

<Art4>1030</Art4>

<Art5>1040</Art5>

<Art6>1050</Art6>

<Art7>1060</Art7>

<Art8>1070</Art8>

<Art9>1080</Art9>

       </Art_List>

 

I can already read the numbers inside every child. I would like to fill a ring on the panel with the name of childs (Art numbers) and the numbers inside to compare them

Dokument = xml_funktionen_Open_Document (Path);

// Art_list
Childinfos = xml_funktionen_Get_Child_Information (Dokument->hRoot, "Art_list", "", "");
Subchildinfos = xml_funktionen_Get_All_Childs (Childinfos->hHandle);

Subchildinfos = xml_funktionen_Get_All_Childs (Childinfos->hHandle);
if(Childinfos->inumChild <= 0) Main_ERROR(SYS_REF_LADEN_ARTIKEL, SYSTEMFEHLER);


sRef_Data.cArtikelliste = calloc (Childinfos->inumChild*sizeof(char*), 1);
for (int i=0; i<Childinfos->inumChild; i++)
{
sRef_Data.Art_list[i] = calloc ((Subchildinfos->iMax_Child_Value_Length+1)*sizeof(char*)/4, 1);
}
// fill the Art_list
for(int i = 0; i<Childinfos->inumChild; i++)
{
Fmt(sRef_Data.Art_list[i], "%s<%s", Subchildinfos->cChild_Values[i]);
}
sRef_Data.iNum_Art = Childinfos->inumChild;


xml_funktionen_Close_Document(Dokument->hDokument);

 

0 Kudos
Message 1 of 2
(1,103 Views)
Solution
Accepted by topic author Ramles97

I don't know which library you have used to read the XML file, but are you aware of the cvixml.fp instrument? With that you can read the XML file and get tag and value for the elements in your file with which to fill your list.

 

CVI comes also with an example program of how to use the instrument: this is how your XML file looks like when read from XMLSample program:

Screenshot 2021-08-24 17.59.21.png

 

You can find the example program by using the Example Finder (Help >> Find Examples...) and searching for "XML"



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(1,085 Views)