MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / copy

Method copy

src/main/java/org/htmlunit/util/XmlUtils.java:310–345  ·  view source on GitHub ↗

Copy all children from 'source' to 'dest', within the context of the specified page. @param page the page which the nodes belong to @param source the node to copy from @param dest the node to copy to @param handleXHTMLAsHTML if true elements from the XHTML namespace are handled as HTML elements inst

(final SgmlPage page, final Node source, final DomNode dest,
        final boolean handleXHTMLAsHTML)

Source from the content-addressed store, hash-verified

308 * DOM elements
309 */
310 private static void copy(final SgmlPage page, final Node source, final DomNode dest,
311 final boolean handleXHTMLAsHTML) {
312 final NodeList nodeChildren = source.getChildNodes();
313 for (int i = 0; i < nodeChildren.getLength(); i++) {
314 final Node child = nodeChildren.item(i);
315 switch (child.getNodeType()) {
316 case Node.ELEMENT_NODE:
317 final DomNode childXml = createFrom(page, child, handleXHTMLAsHTML);
318 dest.appendChild(childXml);
319 copy(page, child, childXml, handleXHTMLAsHTML);
320 break;
321
322 case Node.TEXT_NODE:
323 dest.appendChild(new DomText(page, child.getNodeValue()));
324 break;
325
326 case Node.CDATA_SECTION_NODE:
327 dest.appendChild(new DomCDataSection(page, child.getNodeValue()));
328 break;
329
330 case Node.COMMENT_NODE:
331 dest.appendChild(new DomComment(page, child.getNodeValue()));
332 break;
333
334 case Node.PROCESSING_INSTRUCTION_NODE:
335 dest.appendChild(new DomProcessingInstruction(page, child.getNodeName(), child.getNodeValue()));
336 break;
337
338 default:
339 if (LOG.isWarnEnabled()) {
340 LOG.warn("NodeType " + child.getNodeType()
341 + " (" + child.getNodeName() + ") is not yet supported.");
342 }
343 }
344 }
345 }
346
347 /**
348 * Search for the namespace URI of the given prefix, starting from the specified element.

Callers 5

appendChildMethod · 0.95
saveAsMethod · 0.45
saveAsMethod · 0.45
saveAsMethod · 0.45
saveResponseMethod · 0.45

Calls 10

getLengthMethod · 0.95
itemMethod · 0.95
getNodeTypeMethod · 0.95
createFromMethod · 0.95
getNodeValueMethod · 0.95
getNodeNameMethod · 0.95
isWarnEnabledMethod · 0.65
warnMethod · 0.65
getChildNodesMethod · 0.45
appendChildMethod · 0.45

Tested by

no test coverage detected