My second example is the one returning [function getValue] and I’m trying to fix it but I can’t see what the problem is.
I’ve been messing around with xmlparse in google scripts, the xml I want to parse keeps all relevant data in the attributes of elements.
Here’s a sample of that xml format: https://api.eveonline.com/account/characters.xml.aspx?keyID=1409941&vCode=xagxMH966J2EQinVpoFOBB5H1UidCwsjoTwtBKhhvMVZWqq6Jio4mkiBwv026Olc
Here’s some code that works (displayed via log [ctrl]+[enter]):
function dialogDisplay() {
var xmlstring = Xml.parse('<rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID"><row name="Jonah Younbrog" characterID="90131303" corporationName="House of Praetor" corporationID="523373135"/><row name="Mador Younbrog" characterID="90149709" corporationName="House of Praetor" corporationID="523373135"/><row name="Marc Younbrog" characterID="747451028" corporationName="House of Praetor" corporationID="523373135"/></rowset>');
var attributes = xmlstring.getElement().getAttributes();
for (var i in attributes) {
Logger.log(attributes[i].getValue());
}
}
And here’s the code that doesn’t work, it also logs the element names (successfully) and uses nested fors to go through the xml:
function fetchToLogger() {
var assetURL = "https://api.eveonline.com/account/characters.xml.aspx?keyID=1409941&vCode=xagxMH966J2EQinVpoFOBB5H1UidCwsjoTwtBKhhvMVZWqq6Jio4mkiBwv026Olc";
var assetstring = UrlFetchApp.fetch(assetURL).getContentText();
var xmlstring = Xml.parse(assetstring, false);
var elements = xmlstring.eveapi.result.getElements();
for (var a in elements) {
Logger.log(elements[a].getName().getLocalName());
var attributes = elements[a].getAttributes();
for (var x in attributes) {
Logger.log(attributes[x].getValue);
}
var subelements = elements[a].getElements();
for (var b in subelements) {
Logger.log(subelements[b].getName().getLocalName());
var subattributes = subelements[b].getAttributes();
for (var y in attributes) {
Logger.log(attributes[y].getValue);
}
}
}
}
.getValueis a function. so you should use.getValue()For example: