Organizational Research By

Surprising Reserch Topic

generate xml out of textfile using json decode using -'php,json,xml,rss'

generate xml out of textfile using json decode  using -'php,json,xml,rss'

I have this Textfile (namelist.txt):

  {"0":"Mr Tony Test","1":"Ms Tina Testy"}

And I try to convert it into XML:

$xml = new DOMDocument();
$names = json_decode(file_get_contents('namelist.txt'));
foreach ($names as $name)
    $xml_name = $xml->createElement($name);


I get the following Error:

  Fatal error: Uncaught exception 'DOMException' with message 'Invalid
  Character Error' in C:\xampp\htdocs\xibo\rss.php:6 Stack trace: #0
  C:\xampp\htdocs\xibo\rss.php(6): DOMDocument->createElement('Mr  Tony
  Te...') #1 {main} thrown in C:\xampp\htdocs\xibo\rss.php on line 6

Is is even possible like this?

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.