GO-V.ORG
As seen in

Search e01

One query across the encyclopedia, books, dictionary, papers, Wikidata and the developer library. Every hit carries its source.

6 results across 6 corpora for DOMParser: parseFromString() method.

Developer library 6

webRequest.StreamFilter.ondata

); }; filter.onstop = async (event) => { const blob = new Blob(data, { type: "text/html" }); const str = await blob.text(); const doc = parser.parseFromString(str, blob.type); const nodes = doc.querySelectorAll("title, h1"); for (const node of nodes) { node.innerText = node.innerText.replaceAll("Example", "WebExtension $&"); } filter.write(encoder.encode(doc.documentElement.oute

Parsing and serializing XML

a string into a DOM tree using a DOMParser: ```js const xmlStr = '<q id="a"><span id="b">hey!</span></q>'; const parser = new DOMParser(); const doc = parser.parseFromString(xmlStr, "application/xml"); // print the name of the root element or error message const errorNode = doc.querySelector("parsererror"); if (errorNode) { console.log("error while parsing"); } else { console.log(doc.documentElement.nodeName);

Document: createProcessingInstruction() method

usage This example creates an `<xml-stylesheet>` processing instruction and adds it to the top of an example XML document. ```js const doc = new DOMParser().parseFromString("<foo />", "application/xml"); const pi = doc.createProcessingInstruction( "xml-stylesheet", 'href="mycss.css"', ); doc.insertBefore(pi, doc.firstChild); console.log(new XMLSerializer().serializeToString(doc)); // Displays: <?xml-styleshe

Document: createComment() method

`data` - : A string containing the data to be added to the Comment. ### Return value A new Comment object. ## Examples ```js const doc = new DOMParser().parseFromString("<xml></xml>", "application/xml"); const comment = doc.createComment( "This is a not-so-secret comment in your document", ); doc.querySelector("xml").appendChild(comment); console.log(new XMLSerializer().serializeToString(doc)); // Displays

Document: parseHTMLUnsafe() static method

bility ## See also - Document.parseHTML() - Element.setHTML() and Element.setHTMLUnsafe() - ShadowRoot.setHTML() and ShadowRoot.setHTMLUnsafe() - DOMParser.parseFromString() for parsing HTML or XML into a DOM tree - [HTML Sanitizer API](/docs/Web/API/HTML_Sanitizer_API)

Document: createCDATASection() method

e data to be added to the CDATA Section. ### Return value A [CDATA Section](/docs/Web/API/CDATASection) node. ## Examples ```js const doc = new DOMParser().parseFromString("<xml></xml>", "application/xml"); const cdata = doc.createCDATASection("Some <CDATA> data & then some"); doc.querySelector("xml").appendChild(cdata); console.log(new XMLSerializer().serializeToString(doc)); // Displays: <xml><![CDATA[Some <CDA

JSON results · Services directory