Is it acceptable to create your DOMDocument, and then create a number of elements with createElement() and than populate the elements with appendChild in a random order and then when you go to output the document and have everything where it should go, or is the XML buffer in php "building it as you make the calls"?
$xml = new DOMDocument("1.0",'utf-8');
$xml->formatOutput=true;
$rootxml = $xml->createElement("TDNS","root element");
$xml->appendChild($rootxml);
//=====================================================
// IS IT LEGAL TO CREATE SEVERAL ELEMENTS LIKE THIS ALTOGETHER
//=====================================================
$parta=$xml->createElement("astuff");
$partb=$xml->createElement("bstuff");
$partc=$xml->createElement("cstuff");
// and then POPULATE them in any order, like this?
$infoa=$xml->createElement("info_a",$inputa); // adding to part A
$parta->appendChild($infoa);
$infob=$xml->createElement("info_b",$inputb); // adding to part A
$parta->appendChild($infob);
$infoc=$xml->createElement("info_c",$inputc); // adding to part B
$partb->appendChild($infoc);
// THEN MAYBE ADD SOMETHING TO PART C AND THEN A, AND THEN B
// (you can say why would you do that, but sometimes it is easier to
// extract data out of a data sort in the order it is provided and
// assemble it in the correct order on output, it can make the coding
// much more efficient)
...
// THEN APPEND all the elements into the main XML Document
$xml->appendChild($parta)
$xml->appendChild($partb)
$xml->appendChild($partc)
// THEN PRINT OUTPUT
$xml->saveXML();
Is it acceptable to create your DOMDocument, and then create a number of elements with createElement() and than populate the elements with appendChild in a random order and then when you go to output the document and have everything where it should go, or is the XML buffer in php "building it as you make the calls"?
$xml = new DOMDocument("1.0",'utf-8');
$xml->formatOutput=true;
$rootxml = $xml->createElement("TDNS","root element");
$xml->appendChild($rootxml);
//=====================================================
// IS IT LEGAL TO CREATE SEVERAL ELEMENTS LIKE THIS ALTOGETHER
//=====================================================
$parta=$xml->createElement("astuff");
$partb=$xml->createElement("bstuff");
$partc=$xml->createElement("cstuff");
// and then POPULATE them in any order, like this?
$infoa=$xml->createElement("info_a",$inputa); // adding to part A
$parta->appendChild($infoa);
$infob=$xml->createElement("info_b",$inputb); // adding to part A
$parta->appendChild($infob);
$infoc=$xml->createElement("info_c",$inputc); // adding to part B
$partb->appendChild($infoc);
// THEN MAYBE ADD SOMETHING TO PART C AND THEN A, AND THEN B
// (you can say why would you do that, but sometimes it is easier to
// extract data out of a data sort in the order it is provided and
// assemble it in the correct order on output, it can make the coding
// much more efficient)
...
// THEN APPEND all the elements into the main XML Document
$xml->appendChild($parta)
$xml->appendChild($partb)
$xml->appendChild($partc)
// THEN PRINT OUTPUT
$xml->saveXML();
I finally went to OpenAI and discussed the issue with it and it explained that you cannot do things out of order as it will interfere with the nesting it tries to output properly formatted XML.