title: Access to DOM using node.js
body: <p>i want to access to html file and get an element by id using node.js, this is my html file :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;title&gt;Diagram &lt;/title&gt;
  
  &lt;script&gt;
  
      function generatePNG (oViewer) {
  // some other code
              reader.onloadend = function() {
                  base64data = reader.result;
                  var image = document.createElement('img');
                  image.setAttribute("id", "GraphImage");
                  image.src = base64data;
                  document.body.appendChild(image);
              }
  
          }, "image/png", oImageOptions);
          return sResult;
  
          var sResult = generatePNG (oEditor.viewer);
  
      });
  &lt;/script&gt;
  
  
  &lt;/head&gt;
  
  &lt;body &gt;
      &lt;div id="diagramContainer"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to do get  <code>document.getElementById("GraphImage").src</code> but with node.js.
  I've found that I can use <code>cheerio</code> or <code>jsdom</code> to acces the <code>DOM</code> with node.js, so I've tried this code with <code>cheerio</code>:</p>
  
  <pre><code>var cheerio = require('cheerio'),
      $ = cheerio.load('file.html');
  </code></pre>
  
  <p>But I didn't founnd the instruction that allow me to get the <code>image.src</code> from the html file, like this instruction: <code>document.getElementById("GraphImage").src</code></p>