title: How to parse HTML/XML documents with Node.js?
body: <p>I have an <code>editor.html</code> that contains <code>generatePNG</code> function:</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 type="text/javascript" src="lib/jquery-1.8.1.js"&gt;&lt;/script&gt; 
  //    &lt;!-- I use many resources --&gt;
  &lt;script&gt;&lt;/script&gt; 
  
      &lt;script&gt; 
  
          function generatePNG (oViewer) { 
              var oImageOptions = { 
                  includeDecoratorLayers: false, 
                  replaceImageURL: true 
              }; 
  
              var d = new Date(); 
              var h = d.getHours(); 
              var m = d.getMinutes(); 
              var s = d.getSeconds(); 
  
              var sFileName = "diagram" + h.toString() + m.toString() + s.toString() + ".png"; 
  
              var sResultBlob = oViewer.generateImageBlob(function(sBlob) { 
                  b = 64; 
                  var reader = new window.FileReader(); 
                  reader.readAsDataURL(sBlob); 
                  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; 
          } 
  
      &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 access the DOM and get <code>image.src</code> using Node.js. I find that I can work with cheerio or jsdom.</p>
  
  <p>I start with this:</p>
  
  <pre><code>var cheerio = require('cheerio'),
      $ = cheerio.load('editor.html');
  </code></pre>
  
  <p>But I don't find how to access and get <code>image.src</code>.</p>