1
Hello, guys. I’m having problems with the . each of jQuery. I have an xml like this:
<dados>
<usuarios>
<usuario id="1">
<login>usuario12</login>
<senha>21</senha>
</usuario>
<usuario id="2">
<login>usuario23</login>
<senha>23</senha>
</usuario>
</usuarios>
and I’m trying to read it like this with jQuery:
$(xml).find("usuarios").each(function() {
console.log($(this).find("usuario").text());
});
but the console shows me so:
user 1212user 2323
Can you help me?
What you hoped to receive on the console?
– Sergio
I expected to receive something like a "{login: user, password: pswd}" object, you know?
– Krint
Okay, that’s not what the answer you marked as accepted gives you, but I imagine you were able to do the rest.
– Sergio
Actually with the answer code I was able to get the login object and the password object separately. Before I was just getting a string run with all the information
– Krint