xmlTreeAddChild

 

SYNOPSIS

    xmlNode xmlTreeAddChild(xmlNode parent, xmlNode child)

Parameters:

  • parent - The node that you want to assign the child to.

  • child - The node that you want to move to being a child of parent.

Returns:

  • the child


DESCRIPTION
xmlTreeAddChild() adds the node child as a child of parent. If it was already in an XML document, it is fully removed from its original location. The child is appended at the end of the list of the parent's children.


EXAMPLE
Given the XML document

<top>
    <item>item 1</item>
    <item>item 2</item>
    <summary>
        <name>Squiggy</name>
        <detail>fuzzy</detail>
        <color>blue</color>
        <size>big</size>
    </summary>
</top>

The command

    <$ret = (xmlTreeAddChild($top, $detail))>

Would result in:

<top>
    <item>item 1</item>
    <item>item 2</item>
    <summary>
        <name>Squiggy</name>
        <color>blue</color>
        <size>big</size>
    </summary>
    <detail>fuzzy</detail>
</top>


CAVEATS
If this operation results in two text nodes being siblings of each other, the second node will be merged into the first and then unlinked. Any changes made to the second text node will not be reflected in the tree.


SEE ALSO
xmlTreeAddChildList, xmlTreeAddNextSibling, xmlTreeAddPrevSibling, xmlTreeAddSibling, xmlTreeSetRootElement


Copyright © Thunderstone Software     Last updated: Dec 10 2018
Copyright © 2019 Thunderstone Software LLC. All rights reserved.