Question

I'm working on making a DOM XML file using Php (for JW Player) How do I create this element:

<media:content url="foo.mp4" />

I've tried this:

$mediacontent = $dom->createElement('media:content', 'foo.mp4');
$item->appendChild($mediacontent);

But it only generates: <media:content>foo.mp4</media:content>

Était-ce utile?

La solution

This solved it:

$mediacontent = $dom->createElement('media:content');
$item->appendChild($mediacontent);
$url = $dom->createAttribute('url');
$mediacontent->appendChild($url);
$urlvalue = $dom->createTextNode('../movies/Dropbox/'.$filename.'');
$url->appendChild($urlvalue);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top