title: Understanding output of util.inspect
body: <p>A RESTFul API's method I'm calling from node gives me the following XML Response: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;tsResponse xmlns="http://tableausoftware.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableausoftware.com/api http://tableausoftware.com/api/ts-api-2.0.xsd"&gt;
    &lt;credentials token="xyzzy"&gt;
      &lt;site contentUrl=""/&gt;
    &lt;/credentials&gt;
  &lt;/tsResponse&gt;
  </code></pre>
  
  <p>My ultimate goal is to grab the value of the <strong>token</strong> attribute associated with the <strong>credentials</strong> element and assign it to a variable in "my first node app". </p>
  
  <p>My first stab at this involved using a module called xml2js. I'm able to convert the response above to a JS object, but then I had a hell of a time making sense of what I was left with. </p>
  
  <p>I managed to accomplish my goal, but I really don't understand how I got there...it was pure trial and error on my part, really: </p>
  
  <pre><code>var parseString = require('xml2js').parseString;
  ...
  parseString(response, function (err, result) {
                      console.log(util.inspect(result, false, 7));
                      tokencontainer = (result.tsResponse.credentials);
                      token = tokencontainer[0].$.token;
                  });
  </code></pre>
  
  <p>The output of util.inspect is as follows:</p>
  
  <pre><code>{ tsResponse: 
     { '$': 
        { xmlns: 'http://tableausoftware.com/api',
          'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
          'xsi:schemaLocation': 'http://tableausoftware.com/api http://tableausoftware.com/api/ts-api-2.0.xsd' },
       credentials: 
        [ { '$': { token: 'xyzzy' },
            site: [ { '$': { contentUrl: '' } } ] } ] } }
  </code></pre>
  
  <p>Can someone explain to me what this actually means? Even though I'm just playing with this for kicks, I want to understand what I'm looking at. For example: </p>
  
  <ul>
  <li>How would I reference the <strong>xsi:schemalocation property</strong> (or is it a
  key?) in JS? </li>
  <li>I'm sure I could reference the token value in a more
  concise fashion than I managed. How? </li>
  <li>What are those dollar signs there for? What do they signify?</li>
  </ul>
  
  <p>...and of course, if there's a better way to approach this than using xml2js, I'm all ears. However I still want to understand what's going on above since it's new to me...</p>
  
  <p>Thanks much</p>