I read this xml and trying to get different nodes value. I can just look for a specific node and get the value but the problem is there are multiple nodes with the same name. So when I get the value it gives me all the nodes value that I specified. I want to get each node value separately. Any help will be appreciated. Thanks in advance.
Here is the xml:
<LogLine>
<DateTime>2016-11-17T16:48+0000</DateTime>
<Operation>Register1</Operation>
</LogLine>
<LogLine>
<DateTime>2016-11-17T16:48+0000</DateTime>
<Operation>Register2</Operation>
</LogLine>
<LogLine>
<DateTime>2016-11-17T16:48+0000</DateTime>
<Operation>Register3</Operation>
</LogLine>
What I have done
success: function(xml) {
var xmlDoc = jQuery.parseXML(xml);
xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc ),
$dateTime = $xml.find( "DateTime" );
$( "#xmlElement" ).append( "Log In Information: "+$dateTime .text() );
}
HTML:
Current output: 2016-11-17T18:31+00002016-11-17T18:31+00002016-11-17T18:31+0000
$dateTimeis an array, try selecting the specific value like this:$dateTime[0].text()