i created a XML document using DOMDocument and simpleXML. I need to add an attibute to the root element.
Below is how I created the document and the element. You will note that although the document is initally created by DOMDocument, the child/user nodes are created with simple XML.
$dom = new DOMDocument('1.0','UTF-8');
/*** create the root element ***/
$root = $dom->appendChild($dom->createElement( "Feed" ));
/*** create the simple xml element ***/
$sxe = simplexml_import_dom( $dom );
/*** add a user node ***/
$firstChild = $sxe->addchild("FirstChild");
I tried adding the attibutes to the root like this:
$root = $dom->appendData($dom->createAttribute("extractDate", "$now"));
but this does not work.