User Tools

Site Tools


wap:wap

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wap:wap [2017/02/20 14:52] – created georgewap:wap [2017/02/20 15:57] (current) george
Line 5: Line 5:
   * [[https://www.w3schools.com/xml/xml_examples.asp|XML examples]]   * [[https://www.w3schools.com/xml/xml_examples.asp|XML examples]]
     * [[https://www.w3schools.com/xml/books.xml|books xml]]     * [[https://www.w3schools.com/xml/books.xml|books xml]]
 +  * [[https://www.w3schools.com/xml/schema_facets.asp|XML Schema Restrictions examples]]
   * [[https://www.w3schools.com/xml/xpath_examples.asp|XPath examples]]   * [[https://www.w3schools.com/xml/xpath_examples.asp|XPath examples]]
   * [[https://www.w3schools.com/xml/xsl_examples.asp|XSLT examples]]   * [[https://www.w3schools.com/xml/xsl_examples.asp|XSLT examples]]
 +
 +===== Snippets =====
 +
 +  * xpath example - showResult modification
 +
 +<code javascript>
 +<!DOCTYPE html>
 +<html>
 +<body>
 +
 +<p id="demo"></p>
 +
 +<script>
 +var path = "/*";
 +var xhttp = new XMLHttpRequest();
 +xhttp.onreadystatechange = function() {
 +    if (this.readyState == 4 && this.status == 200) {
 +        showResult(xhttp.responseXML);
 +    }
 +};
 +xhttp.open("GET", "books.xml", true);
 +xhttp.send(); 
 +
 +function showResult(xml) {
 +    var txt = "";
 +    var s = new XMLSerializer();
 +    if (xml.evaluate) {
 +        var nodes = xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
 +        var result = nodes.iterateNext();
 +        while (result) {
 +            txt += "<b>" + result + " : " + result.tagName + "</b></br>"
 +            txt += result.childNodes[0].nodeValue + "<br>";
 +            txt += s.serializeToString(result) + "<br><br>";
 +            result = nodes.iterateNext();
 +        } 
 +    // Code For Internet Explorer
 +    } else if (window.ActiveXObject || xhttp.responseType == "msxml-document") {
 +        xml.setProperty("SelectionLanguage", "XPath");
 +        nodes = xml.selectNodes(path);
 +        for (i = 0; i < nodes.length; i++) {
 +            txt += nodes[i].childNodes[0].nodeValue + "<br>";
 +        }
 +    }
 +    document.getElementById("demo").innerHTML = txt;
 +}
 +</script>
 +
 +</body>
 +</html>
 +</code>
wap/wap.1487598720.txt.gz · Last modified: 2017/02/20 14:52 by george

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki