retrieveAttributes that results in [method fetchValue] during a nested loop

My second example is the one returning [function getValue] and I'm in search of a solution to fix it, yet I am struggling to pinpoint the root cause.

Lately, I've been experimenting with xmlparse in Google Scripts. The XML I am attempting to parse has all the necessary data stored in the attributes of its elements.

Here's an excerpt of the XML format: Sample XML Link

Below is some functional code for reference (displayed using 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 problematic code section. It successfully logs the element names and uses nested loops to traverse 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);
      }

    }

  }

}

Answer №1

.retrieveValue is a method that requires the use of .retrieveValue() Take a look at this sample code:

Logger.log(attributes[x].retrieveValue());

Answer №2

Make sure to invoke the function properly by updating it as follows:

Logger.log(attributes[x].getValue());

Remember that

Logger.log(attributes[x].getValue)
is simply a pointer to the function, which is what appears in the console output.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can the value of a button be displayed in an input box using an onclick function?

When the button '1' is clicked, it displays the value "1" inside a <!p> tag. However, the second button '2' does not display the value "2" in the input box. Even though both functions are identical. //Function with working func ...

I'm having trouble defining the domain for the grouped bar chart

While attempting to create a group bar graph using d3.js, I encountered an error that has me stumped. As a newcomer to d3.js, I am actively working on mastering the script independently. Any guidance or assistance from the community would be greatly apprec ...

What could be causing the information from the ajax call to not appear in this popover?

Hovering over a link will trigger a popover with a 1 second delay containing user profile information, loaded using AJAX. $(function() { var timer = null; var xhr = null; $('.user_popup').hover( function(event) { ...

Using Angular with a hapi.js server that supports JSONP data requests

In my project, there is an endpoint specifically set at /api/profile that accepts post parameters. var http = require('http'); var serverConfig = require('../server.config.js'); var request = require('request'); module.expo ...

What is the best way to pass around shared constants within NodeJS modules?

My current approach involves the following steps: foo.js const FOO = 5; module.exports = { FOO: FOO }; I then use it in bar.js: var foo = require('foo'); foo.FOO; // 5 However, I'm wondering if there is a more efficient way to hand ...

Disconnect occurred during execution of Node.js "hello world" on a Windows 7 operating system

Issue Resolved: Oh no! jimw gets 10000 points for the solution! I've decided to delve into a hobby project using Node.js. Here's where I started: Downloaded and installed Node version 0.6.14 Copied and pasted the classic "hello world" program ...

Utilize the Multer file upload feature by integrating it into its own dedicated controller function

In my Express application, I decided to keep my routes.js file organized by creating a separate UploadController. Here's what it looks like: // UploadController.js const multer = require('multer') const storage = multer.diskStorage({ dest ...

Discovering the origin of an unexpected element.style manifestation

I cannot figure out how this strange issue occurred. This is the correct HTML code structure: <nav class="navbar navbar-inverse navbar-fixed-top"> However, Chrome is displaying the following unexpected code: <nav class="navbar navbar-invers ...

Obtain an SVG file using the Wikipedia API

Exploring the possibilities of utilizing the Wikipedia API within node.js. Can I extract solely the SVG files from the Wikipedia API by specifying only the category of these images? ...

Tips for identifying HTML tags that include a specific attribute automatically

Is there a way to automatically identify an HTML tag that contains a specific attribute like data-wow-delay? This query revolves around wow.js. The goal is to have the classes wow bounce added automatically to any HTML tag that has this particular attribu ...

Balancing one cube atop another in a dynamic manner

Currently, I am developing a project using three.js, where users have the ability to dynamically adjust the dimensions of objects within the scene. Specifically, there are two boxes with varying sizes and one box that must always remain positioned on top o ...

I am struggling to locate the source of this mysterious middleware error

I seem to be encountering an issue with a middleware function, resulting in a "middleware is not a function" error message. I'm at a loss as to why this is happening... [Error] TypeError: middleware is not a function Routes JS import express from &ap ...

What benefits does using _.filter have over _.forEach when dealing with the task of evaluating a value and then outputting another value

As a newcomer to JavaScript, I rely heavily on eslint and plugins for guidance. My code is written for an environment with lodash 3.9.3 and must be compatible with Chrome 40, utilizing es5. Here's a snippet of my code: _.forEach(star.syst ...

Encountering a crash issue with JMeter's Selenium Sampler while attempting to click on a button with the Phantom

After building a JMeter Project, I have been utilizing the WebDriver Sampler (Selenium) to monitor response times during interactions with a particular feature on a webpage. To test my project, I have experimented with both Firefox and Chrome Driver confi ...

Retrieve the string saved in a ViewBag when the ajax call is successful

I am new to ASP.NET MVC and have been struggling to find a solution to this problem. Despite searching on various platforms, including Stack Overflow, I have not been able to resolve it. Here are some links to solutions that did not work for me: Possible ...

Challenges with browsing navigation in Selenium WebDriver

Recently, I began my journey of learning selenium WebDriver. In an attempt to automate the task of logging into an account using the Firefox browser, I encountered a discrepancy. Manually opening the browser and clicking on the login link from the homepag ...

Storing an HTML page in a PHP variable, parsing it, and displaying it correctly

I am currently using the simple_html_dom parser to extract information from an HTML page. After making some modifications, I would like to display this content on my own page. $page = file_get_html($url); foreach($page->find('div#someDIv') as ...

Is there a way to utilize jQuery to calculate the total of an unknown quantity of inputs within a table?

I have a dynamic table where users can add or remove rows. My goal is to calculate the total for each row and then sum up all the totals for a grand total as users enter values in the quantity and rate fields. I want this calculation to happen client-sid ...

Three.js: sleek camera sliding gracefully around a central point

I have a challenge with my three.js project where I am rendering a cube in the center of two lines pointing to different directions. To interact with the scene, I am using OrbitControls along with some custom code (refer to the link below) to smoothly tran ...

Why doesn't ngSubmit function inside a modal?

I am experiencing an issue where my submit button is not activating the ng-click angular directive, and I cannot seem to identify the cause. Most people who faced a similar problem did not have their submit button placed inside their form, but I am confi ...