Creating Nodes

New nodes are added to an xmlTree by various new functions. They all take a parent, which specifies where the new node should be created, and either a name and optional content (in the case of elements and attributes), or just content (comments, CDATA, etc).


<$doc = (xmlTreeNewDoc( '1.0'))>
<$root = (xmlTreeNewElement($doc, 'rootNode'))>
<$name = (xmlTreeNewElement($root, 'name', 'John Doe'))>
<$age = (xmlTreeNewElement($root, 'age', '23'))>
<$ret = (xmlTreeNewAttribute($age, 'type', 'years'))>
<$output = (xmlTreePrintDoc($doc, 'INDENT'))>
output is $output

xmlTreeNewElement, xmlTreeNewPI, xmlTreeNewText, xmlTreeNewCDATA, xmlTreeNewComment, xmlTreeNewAttribute, xmlTreeNewNs

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