Jump to content

XML path


FSX30HD

Recommended Posts

phpVMS's acars map draws from the database and not from an xml file.

Thanks for your reply, the map draws from json format and the link is:

/action.php/acars/data

I have found howto output in xml format. I have just make a php file echo rows in xml format. But maybe in ACARS module instead of use json_encode switch to saveXML() like this:

//Creates XML string and XML document using the DOM
$dom = new DomDocument('1.0', 'UTF-8');
//add root == jukebox
$jukebox = $dom->appendChild($dom->createElement('jukebox'));
for ($i = 0; $i < count($arrayWithTracks); $i++) {
 //add track element to jukebox
 $track = $dom->createElement('track');
 $jukebox->appendChild($track);
 // Appending attributes to track
 $attr = $dom->createAttribute('source');
 $attr->appendChild($dom->createTextNode($arrayWithTracks[$i]['source']));
 $track->appendChild($attr);
 $attr = $dom->createAttribute('artist');
 $attr->appendChild($dom->createTextNode($arrayWithTracks[$i]['artist']));
 $track->appendChild($attr);
 $attr = $dom->createAttribute('album');
 $attr->appendChild($dom->createTextNode($arrayWithTracks[$i]['album']));
 $track->appendChild($attr);
 $attr = $dom->createAttribute('title');
 $attr->appendChild($dom->createTextNode($arrayWithTracks[$i]['title']));
 $track->appendChild($attr);
}
$dom->formatOutput = true; // set the formatOutput attribute of domDocument to true
// save XML as string or file
$test1 = $dom->saveXML(); // put string in test1
$dom->save('test1.xml'); // save as file

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...