Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

capionoO
Level 2
Level 2

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
radzmar
Correct answer by
Level 10
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
BarlaeDC
Level 5
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

radzmar
Correct answer by
Level 10
Level 10

Hi,

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