Bonjour,

J'essaie de gerer l'affichage de mes videos grace a un fichier xml, qui contient ma liste. Je récupère un paramètre (url de la vidéo) puis je parcours mon fichier xml pour remonter le nœud de cette vidéo en tête de liste. Mon but est d'afficher un lecteur vidéo avec en tête de liste une certaine vidéo.

C'est la première fois que je fais du DOM xml soyez indulgent svp ^^

Voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
	$objDOM = new DOMDocument();
	$objDOM->load("playlist.xml");
 
        //Recuperation du noeud de la premiere video
	$node = $objDOM->getElementsByTagName("track")->item(0);
 
        // Boucle pour trouver celle a mettre en tete de liste
	$tracks = $objDOM->getElementsByTagName("track");
	foreach($tracks as $value)
	{
		if ($_GET['video'] == $value->getAttribute('name'))
		{
			$clone = $value->cloneNode();
			$value->parentNode->removeChild($value);
			$newNode = $objDOM->insertBefore($clone, $node);//Erreur ici
 
			$objDOM->save("playlist.xml");
		}
	}
Voici mon fichier XML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
<?xml version="1.0"?>
<playlist xmlns="http://xspf.org/ns/0/" version="1">
   <title>Example XSPF playlist for the JW Player</title>
   <info>http://developer.longtailvideo.com/trac</info>
   <tracklist>
      <track name="locationvideo1">
         <title>Video 1</title>
         <creator>Creator de video 1</creator>
         <info>info video 1</info>
         <annotation>Annotations video 1</annotation>
         <location>locationvideo1</location>
      </track>
      <track name="locationvideo2">
         <title>Video 2</title>
         <creator>Creator de video 2</creator>
         <info>info video 2</info>
         <annotation>Annotations video 2</annotation>
         <location>locationvideo2</location>
      </track>
	  <track name="locationvideo3">
         <title>Video 3</title>
         <creator>Creator de video 3</creator>
         <info>info video 3</info>
         <annotation>Annotations video 3</annotation>
         <location>locationvideo3</location>
      </track>
	  <track name="locationvideo4">
         <title>Video 4</title>
         <creator>Creator de video 4</creator>
         <info>info video 4</info>
         <annotation>Annotations video 4</annotation>
         <location>locationvideo4</location>
      </track>
   </tracklist>
</playlist>
Voici mon erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Fatal error: Uncaught exception 'DOMException' with message 'Not Found Error' in C:\wamp\www\test\index.php:16 Stack trace: #0 C:\wamp\www\test\index.php(16): DOMNode->insertBefore(Object(DOMElement), Object(DOMElement)) #1 {main} thrown in C:\wamp\www\test\index.php on line 16
Si vous avez des conseils, n'hésitez pas, je débute et j'ai beaucoup de mal a comprendre.
Merci d'avance