Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8 />
    <title>JS Bin</title>
  </head>
  <body>
    <div style="display: none">
      <div id="priceInfo">
        <div class="standardProdPricingGroup">
          <span>hello</span>
        </div>
      </div>
      <div id="priceInfo">
        <div class="standardProdPricingGroup">
          <span>world</span>
        </div>
      </div>
    </div>
    <pre id="output"></pre>
  </body>
  <script>
    var xpath = '//*[@id="priceInfo"]//div[@class="standardProdPricingGroup"]//span[1]';
    
    var nodeList = [ ];
    var r = document.evaluate(xpath, document.documentElement, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
    for ( var node; node = r.iterateNext( ); )
      nodeList.push( node );
    
    var output = document.getElementById( 'output' );
    output.innerHTML += nodeList.length + ' elements found\n';
    for ( var t = 0, T = nodeList.length; t < T; ++ t )
      output.innerHTML += ' - ' + nodeList[ t ].innerHTML + '\n';
  </script>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers