Html程序  |  37行  |  1.09 KB

<!-- https://sourceforge.net/tracker/?func=detail&atid=106473&aid=418317&group_id=6473 -->
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../../js/resources/js-test-style.css">
<script src="../../../js/resources/js-test-pre.js"></script>
</head>
<body>
<div id="console"></div>

<script>
SRC_1 = '<?xml version="1.0" encoding="utf-8"?>\
<doc>\
<elem>abc</elem>\
<elem><![CDATA[abc]]></elem>\
<elem>a<![CDATA[b]]>c</elem>\
</doc>';

    doc = (new DOMParser).parseFromString(SRC_1, "application/xml");

    EXPR = '/doc/elem/text()'
    nodeset = doc.evaluate(EXPR, doc, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
    actual = "";
    while (currNode = nodeset.iterateNext())
        actual += currNode.nodeValue;
    
    // According to DOM XPath working group note, this should be "abcabca", but we'll rather match Firefox.
    // See <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#TextNodes>.
    shouldBe('actual', '"abcabcabc"')

    var successfullyParsed = true;

</script>
<script src="../../../js/resources/js-test-post.js"></script>
</body>
</html>