Copying Objects

The copying functions behave like the moving functions, except they leave the original copy of the node intact.

There are no namespace copying functions, as it's rare to need to actually copy a namespace. It's more common to simply use xmlTreeSetNs() to tell an object to use a namespace. See the Using Namespaces (here) section for more information.


<rootNode><name>John Doe</name><age>34</age></rootNode>
</capture><$xmlRaw = $ret>
<$doc = (xmlTreeNewDocFromString( $xmlRaw, 'XML_PARSE_NOBLANKS'))>
<$root = (xmlTreeGetRootElement($doc))>
<$age = (xmlTreeGetChildren($root, 'age'))>
<$age2 = (xmlTreeCopyNode($root, $age, 1))>
<$output = (xmlTreePrintDoc($doc, 'INDENT'))>
output is $output

xmlTreeCopyDoc, xmlTreeCopyNode, xmlTreeCopyNodeList, xmlTreeCopyAttribute, xmlTreeCopyAttributeList

Copyright © Thunderstone Software     Last updated: Oct 24 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.