test.html 848 B

12345678910111213141516171819202122232425
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <title>xmldoc browser test</title>
  5. <script type="text/javascript" src="../node_modules/sax/lib/sax.js"></script>
  6. <script type="text/javascript" src="../lib/xmldoc.js"></script>
  7. <script type="text/javascript">
  8. // Demonstrate parsing an in-memory XML string
  9. var xmlString = '<suggestions><book title="Twilight"/><book title="Twister"/></suggestions>'
  10. var suggestions = new XmlDocument(xmlString);
  11. // Demonstrate how toString() will pretty-print an abbreviated version of the XML for debugging
  12. console.log("Parsed: \n" + suggestions);
  13. // Demonstrate a simple eachChild() loop, printing our book titles
  14. suggestions.eachChild(function(book) {
  15. document.write("<p>Found book with title: '" + book.attr.title + "'</p>");
  16. });
  17. </script>
  18. </head>
  19. <body>
  20. </body>
  21. </html>