Link to home
Start Free TrialLog in
Avatar of Software Squirrel
Software SquirrelFlag for United States of America

asked on

Get Node Values from SharePoint List

I was show how to access the responsXML once for my list.  I am trying figure out how to get to the nodes again.  The last time I did it, it was with Chrome Developer tools in the browser.

I have a function like this:

function myFunction(responseXML) {
		console.log(responseXML);
		var itemList = [];
		console.log(responseXML.getElementsByTagName("entry"));
		for (var i = 0; i < responseXML.getElementsByTagName("entry").length; i++) {
			id = responseXML.getElementsByTagName("entry")[i].childNodes[0].childNodes[0].nodeValue;
			title = responseXML.getElementsByTagName("entry")[i].childNodes[20].childNodes[0].childNodes[5].childNodes[0].nodeValue;
			header = responseXML.getElementsByTagName("entry")[i].childNodes[20].childNodes[0].childNodes[7].childNodes[0].nodeValue;
			urlDescription = responseXML.getElementsByTagName("entry")[i].childNodes[20].childNodes[0].childNodes[8].childNodes[0].childNodes[0].nodeValue;
			url = responseXML.getElementsByTagName("entry")[i].childNodes[20].childNodes[0].childNodes[8].childNodes[1].childNodes[0].nodeValue;
			methodType = responseXML.getElementsByTagName("entry")[i].childNodes[20].childNodes[0].childNodes[9].childNodes[0].nodeValue;
			itemList.push(new Item(id, header, title, url, urlDescription, methodType));
		}

Open in new window

Avatar of Mrunal
Mrunal
Flag of India image

Hi Chris
It would be very helpful if you share value of 'responseXML' you are referring.
if you are using jQuery also then you can use below samples:

var AllMemberNodes = $(xml).find('<NodeNameHere>');

Then you can loop like:

var allAttributes = AllMemberNodes[0].attributes.length;
for (var a = 0; a < allAttributes; a++)
{
  AllMemberNodes[0].attributes[a].value;
}

Hope this logic helps you.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial