How to use the xml.parse function in xml

To help you get started, we’ve selected a few xml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fibjs / fibjs / test / xml_suite.js View on Github external
it("xml_files/xml/" + id + ".xml", () => {
            var txt = fs.readTextFile(path.join(__dirname, "xml_files", "xml", id + ".xml"));
            var json = fs.readTextFile(path.join(__dirname, "xml_files", "json", id + ".json"));
            var out = fs.readTextFile(path.join(__dirname, "xml_files", "out", id + ".xml"));

            var xdoc = xml.parse(txt);
            assert.equal(JSON.stringify(dump_dom(xdoc)), json);
            assert.equal(xdoc.toString(), out);

            var xdoc1 = xdoc.cloneNode();
            assert.notEqual(xdoc, xdoc1);
            assert.equal(JSON.stringify(dump_dom(xdoc1)), json);
            assert.equal(xdoc1.toString(), out);

            xdoc1.normalize();
            assert.equal(xdoc1.toString(), out);
            assert.equal(JSON.stringify(dump_dom(xdoc1)), json);
        });
    }
github fibjs / fib-app / demo / defs / user / spec.js View on Github external
it('custom: profile page', () => {
                var rep = http.get(tSrvInfo.serverBase + `${appOptions.viewPathPrefix}/user/profile`, {
                    headers: {
                        Accept: 'text/html'
                    }
                });

                assert.equal(rep.statusCode, 200);
                var html = rep.body.readAll().toString();

                var xdoc = require('xml').parse(html, 'text/html');
                var body = xdoc.body.toString();

                assert.equal(cheerio(body).text().trim(), 'user profile');
            })