createElement("root"); $DOMObject->appendChild($root_element); $root_item1 = $DOMObject->createElement("child1"); $root_element->appendChild($root_item1); $root_item_text1 = $DOMObject->createTextNode("clied1 text"); $root_item1->appendChild($root_item_text1); $root_item1_attribute = $DOMObject->createAttribute("chield1_attribute"); $root_item1->appendChild($root_item1_attribute); $root_item1_attribute_value = $DOMObject->createTextNode("chield1 attribute value"); $root_item1_attribute->appendChild($root_item1_attribute_value); $root_item2 = $DOMObject->createElement("child2"); $root_element->appendChild($root_item2); $root_item_text2 = $DOMObject->createTextNode("clied2 text"); $root_item2->appendChild($root_item_text2); $DOMObject->save('root.xml'); echo $DOMObject->saveXML(); ?>