This forum is now read-only. Please use our new forums! Go to forums
Get value of multiple tags?
Sorry if my question is vague, I don’t really know how to word it. Anyway, in the “Parsing XML” section, I understand (sort of) how we obtain the names from the xml file. How would we go about getting both the species and the names in the same loop?
For example, in that exercise, we have the XML file as follows:
<pets> <pet> <name>Jeffrey</name> <species>Giraffe</species> </pet> <pet> <name>Gustav</name> <species>Dog</species> </pet> <pet> <name>Gregory</name> <species>Duck</species> </pet> </pets>
To get both, instead of getting the elements by tag name “name”, would we get the elements by tag name “pet”? How then would we obtain the values in the “name” and “species” tags?
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency