Insert and append element API examples

The following conceptual examples show the behavior of the z/TPF parser APIs in different circumstances. For each of the following examples, assume a document order of A - B - C - D - E - F, where B, C, and F are child elements of parent A; D and E are child elements of element C. Figure 1 shows a tree diagram of this example. New element G, given different position pointer locations and parents, is appended to, or inserted into, a tree structure. A tree diagram shows the result of the insert and append for each example.
Figure 1. Insert and append A - B - C - D - E - F tree diagram
  • The position pointer is located after element C; create with parent element C:
    A - B - C - D - E - F
              ^
    The following shows the XML structure after you insert new element G:
    A - B - C - G - D - E - F
                  ^
    The following shows the XML structure after you append new element G:
    A - B - C - D - E - G - F
                          ^
  • The position pointer is located after element D; create with parent element C:
    A - B - C - D - E - F
                  ^
    The following shows the XML structure after you insert new element G:
    A - B - C - D - G - E - F
                      ^
    The following shows the XML structure after you append new element G:
    A - B - C - D - E - G - F
                          ^
  • The position pointer is located after element E; create with parent element C:
    A - B - C - D - E - F
                      ^
    The following shows the XML structure after you insert new element G:
    A - B - C - D - E - G - F
                          ^
    The following shows the XML structure after you append new element G:
    A - B - C - D - E - G - F
                          ^
  • The position pointer is located after element C; create with parent element A:
    A - B - C - D - E - F
              ^
    The following shows the XML structure after you insert new element G:
    A - B - C - D - E - G - F
                          ^
    The following shows the XML structure after you append new element G:
    A - B - C - D - E - F - G 
                             ^
  • The position pointer is located after element D; create with parent element A:
    A - B - C - D - E - F
                  ^
    The following shows the XML structure after you insert new element G:
    A - B - C - D - E - G - F
                          ^
    The following shows the XML structure after you append new element G:
    A - B - C - D - E - F - G 
                             ^
  • The position pointer is located after element E; create with parent element A:
    A - B - C - D - E - F
                      ^
    The following shows the XML structure after you insert new element G:
    A - B - C - D - E - G - F
                          ^
    The following shows the XML structure after you append new element G:
    A - B - C - D - E - F - G
                          ^
  • The position pointer is located after element A, C, D, E, or F; create with parent element B:
    A - B - C - D - E - F 
      ^       ^   ^   ^  ^
    The following shows the XML structure after you insert new element G:
    ERROR
                      
    The following shows the XML structure after you append new element G:
    ERROR