LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read Nested roots/Child tags in a xml file

HI,

I have below xml file, can any one please suggest how to read multiple roots and nested child tags.

Here "Main" is the root

Child1 and Child2 are subroots.

 

<?xml version="1.0"?>

 -<Main>

      <r1>104</r1>

      <r2>DK99</r2>

    -<Child1>

     -<Child1_Branch1>

       -<Branch1_row>

             <r1>DATA HW</r1>

             <r2>DATA SW</r2>

             </Branch1_row>

         </Child1_Branch1>

      -<Child1_Branch2>

    -<Branch2_row>

             <r1>DATA HW</r1>

             <r2>DATA SW</r2>

       </Branch2_row>

    </Child1_Branch2>

</Child1 >

    -<Child2>

-<Child2_Branch1>

    - <Branch1_row>

             <r1>DATA HW</r1>

             <r2>DATA SW</r2>

       </Branch1_row>

    </Child2_Branch1>

-<Child2_Branch2>

    -<Branch2_row>

             <r1>DATA HW</r1>

             <r2>DATA SW</r2>

       </Branch2_row>

    </Child2_Branch2>

</Child2>

</Main>

0 Kudos
Message 1 of 7
(3,543 Views)

Hello bsnayana,

are you aware of the XML instrument driver shipped with CVI? It permits reading / writing XML files and it could help you in handling your data.

You should have a XMLTree example on your machine that demintrates how to use the instrument to read an XML file and display its informations in a tree control.



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 7
(3,539 Views)

Yes, I have but still i am not able to read the child tags inside each nested root (Child1 and Child2).

please suggest the function name which exactly points to the next root reference.

0 Kudos
Message 3 of 7
(3,531 Views)

Well, I copied your text into a new .xml file and was able to view its content with XMLTree project, provided I deleted all hyphens preceding '<' start tag characters.

Exploring the code you should be able to see haw it addresses the elements in the file.



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?
0 Kudos
Message 4 of 7
(3,523 Views)

Didn't get what exactly XML tree. i am new to this XML reading stuff. can you please share your project file.

0 Kudos
Message 5 of 7
(3,517 Views)

XMLTree is a public example which is loaded on your PC while installing CVI. You can locate it under <CVI example folder>\apps\xmltree folder.

Display the Welcome page and click on Explore examples... link, or launch the Example finder and search for XML: you should see listed this example together with <CVI example folder>\toolbox\XMLSample project.



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?
0 Kudos
Message 6 of 7
(3,512 Views)

Thanks.

0 Kudos
Message 7 of 7
(3,495 Views)