Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How can I count the number of elements in an XML file using Javascript without jQuery?

Hello,

Please, help me with this issue...

I have an XML file.

The structure file is...

<?xml version='1.0' encoding='ISO-8859-1'?> <Teams> <Team id="1" name="Real Madrid" paisId="1"> <Players> <Player id="1" squadNumber="1" position="Portero"> <Name> <FirstName>Iker</FirstName> <LastName>Casillas Fernández</LastName> </Name> </Player> <Player id="2" squadNumber="4" position="Defensa"> <Name> <FirstName>Sergio</FirstName> <LastName>Ramos García</LastName> </Name> </Player> </Players> </Team> <Team id="2" name="Atlético Madrid" paisId="1"> <Players> <Player id="3" squadNumber="4" position="Centrocampista"> <Name> <FirstName>Mario</FirstName> <LastName>Suárez Mata</LastName> </Name> </Player> <Player id="4" squadNumber="8" position="Defensa"> <Name> <FirstName>Raúl</FirstName> <LastName>García Escudero</LastName> </Name> </Player> </Players> </Team> </Teams>

I need to count the number of players and the number of players by team and show this values in an HTML file.

I am learning Javascript and I do not know how to connect the .JS file with the XML file.

Thank you.