Sometimes I find Maple a bit unconsequent regarding indexing, some things start with 0, others with 1.
The ReplaceChild function clearly starts with 1 for example, as you see in the help function.
ReplaceChild( 2 = XMLElement( "NEW", , "text" ), doc )
replaces the second element in the list.
When using the AddChild function, one has to enter 0.
The AddChild(xmlTree, child, n) command creates a new XML element from xmlTree by inserting the XML element child at the position indicated by n. Parameter n must be less than or equal to the number of children in the original tree xmlTree. The new child node child becomes the n + 1st child of the resulting tree.
The first sentence sounds logical, but I would then expect the position of the first element to be 1. The other 2 sentences in the help file contradict the first one in my opinion. Either the position of the element is 0, as stated in the first sentence - then it also should be possible to get its value in the position 0. Or it is 1, but then it also should have been defined at position 1.