Expand my Community achievements bar.

SOLVED

How to check if an xml element has child element using xfa?

Avatar

Former Community Member

For instance,  I have an xml like the one below:

<Root>

     <Sites>

               <Site ID="1">

                              <Projects>

                                   <DownTown>

                                             <Project>

                                                  <Funds/>

                                             </Project>

                                             <Project>

                                                  <Funds/>

                                              </Project>

                                             <Project>

                                                  <Funds/>

                                             </Project>

                                   </DownTown>

                         </Projects>

               </Site>

     </Sites>

</Root>

How do you check if the funds element have a child element?

Thanks for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

you can use a loop to determine all childs of a specific node like "Projects".

View solution in original post

2 Replies

Avatar

Level 5

Hi,

Assuming this is used as a data file and assuming you have resolved to the Funds node you should be able to just call Funds.nodes.length.

e.g.

var Funds = xfa.datasets.data.resolveNode ("pathToFundsNode");

if ( Funds.nodes.length > 0)

{

     // Funds has children nodes;

}

Hope this helps

Malcolm

Avatar

Correct answer by
Level 10

Hi,

you can use a loop to determine all childs of a specific node like "Projects".