Link to home
Create AccountLog in
Avatar of kevp75
kevp75Flag for United States of America

asked on

PHP writing XML Issue

I am having a hard time with this.  It produces the following error:
Fatal error: Call to undefined method DOMNodeList::appendChild() in wwwroot\applications\gallery\add.php on line 94  (which in the code below is the first $root->appendChild())

code to follow
$doc = new DOMDocument();
		$doc->load($Img_Storage);
		
		$root = $doc->getElementsByTagName("Album");
		$doc->formatOutput=true;
		
		$img_Node = $doc->createElement("img");
		$root->appendChild($img_Node);
		
		// create attribute node
		$file = $doc->createAttribute("file");
		$img_Node->appendChild($file);
		// giv it a value
		$filename = $doc->createTextNode($userfile_name);
		$file->appendChild($filename);
 
		$save_XML = $doc->save($Img_Storage);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of favoretti
favoretti
Flag of Netherlands image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of kevp75

ASKER

doh!...i probably should have known that...

any idea why the formatting gets screwed up?  It writes...but it appends everything it rights to one line....kinda makes the xml file a bit difficult to read...
Dunno about format, normally formatOutput set to true should give you pretty formatted XML...

SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account