Get Node Values - Loop

2 minutes
Share the link to this page
Copied
  Completed
We can loop over all of the nodes in an XML file to aid in the traversal of XML nodes.

Transcript

Hello, in this video, we are going to take a look at getting the node values using a loop because at the moment we have, you know, the root node, and we have two notes in there and to access each note, we can specify local races 01 get the first one, we'll get the second ones, we have loads of them or, you know, more importantly, we don't if we have an unspecified amount, you know, that could vary, then, you know, this just really isn't gonna work. But luckily for us, we can actually just use a form for each we click the for each, and we just say dollar pot. And you say children, so you'll get all the children as they say dollar note and then we don't need left. Does that What we're going to do is enclose all this in brackets and replace past with dollar notes.

And because we don't have to specify this like specifically anymore, we can literally delete it. So because we're using it for it, he will loop over every single note. And if we run it, it should still run the same way. So let me just create another note so I can show you that it is dynamically working. So let's say to Yoda, from Darth Vader, and Godot the heading is good old days. Do you remember when I Add do you spell part one?

Okay actually matter. pad that one. Okay pedo Okay, so yeah, and if we refresh, as you can see he gets the next one. So that's how you use a loop to go over literally all of the data in the XML file. Obviously it assumes you know, the general structure freedom then can't really do too much. But yeah, that's it.

Any questions, feel free to drop me a message. And as usual, I look forward to seeing you in the next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.