0

Please help me find out where I mistake. I'm trying to create xml from php file to make a playlist for JWPlayer 6, however I can't figure out this error from XML:

error on line 1 at column 158: AttValue: " or ' expected

// xml
header("Content-Type: text/xml; charset=utf-8");
$xml    =   "<rss version='2.0' xmlns:jwplayer='http://rss.jwpcdn.com/'><channel><item>";
$xml    .=  "<title>".$play[0][0]."</title><description></description><jwplayer:image></jwplayer:image><jwplayer:source file=".$provider.$code."/></item>";
$xml    .=  "</channel></rss>";
echo $xml;
exit();
No Hope 212
  • 21
  • 1
  • 5

1 Answers1

0

The part where you create jwplayer:resource element is not correct :

<jwplayer:source file=".$provider.$code."/>

You missed the quotes around file attribute value :

<jwplayer:source file='".$provider.$code."'/>
har07
  • 88,338
  • 12
  • 84
  • 137
  • If I do that, I get this error: **error on line 1 at column 157: Unescaped '<' not allowed in attributes values** – No Hope 212 Oct 08 '16 at 08:16
  • @NoHope212 If `$provider` and/or `$code` may contains `<`, then you'll need [escape that character](http://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents). – har07 Oct 08 '16 at 08:18
  • Please read the following and try to fix it by yourself first : [How do you make strings XML“safe”?](http://stackoverflow.com/questions/3426090/how-do-you-make-strings-xmlsafe). Post a new question if you still can't apply solution suggested there to your case. – har07 Oct 08 '16 at 08:23