Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a non-W3c XML file from Jazler Radio Star Software 1

Status
Not open for further replies.

KNKL

Systems Engineer
Oct 30, 2018
9
US
Hi I'm setting up a radio station with Jazler RadioStar. This program has no forum, and I found that some one else was trying to use the data set that the program generates for what is currently playing, what is going to be played and what has been played. This thread here:
thread426-1655339

Jazler looks like its designed more for the on air radio station (just like a Scott System) , but it does have xml export and auto ftp functions to upload xml files and one htm file they graciously built in one SOAP instance. Unfortunately, they only do a SOAP formatting for the now playing xml file, and leave the others in the C++/ASP format instead of the W3c format, so the typical xml parser will not work.

I decided to make a php server at the station so it can format the files, then ftp them to the web where the flat text files can be appended to the page instead of relying on client side script that may not work in all browsers. On a second function of this, I need to send the shoutcast server the track update. In this thread, I will be posting my server side code (php) as well as the html web page parts so others don't have to go through this coding conundrum.

So our first step is setting up the system. This is a multi user system, where you have the DJ, a production manager, news room, and content auditor workstations with a centralized file server that they all can play/edit/record to. So, I install CentOs on my newly wiped Dell Server the Scott system used to use. I also install a PHP/mysql/nginx to make a song metadata encoding server. Next will be the fun part of setting up all of this.


But to show you by what I mean non W3c format:

<Event status="coming up">
<Song title="Freeway Of Love">
<Artist name="Aretha Franklin" ID="" URL=""/>
<Info StartTime="03:35:36" JazlerID="1843" PlayListerID="" /> <Media runTime="05:44"/>
<SongURL></SongURL>
<SongBarCode></SongBarCode>
<SongCDKey></SongCDKey>
</Song>
<Song title="All I Need Is A Miracle">
<Artist name="Mike &amp; The Mechanics" ID="" URL=""/>
<Info StartTime="03:41:20" JazlerID="2538" PlayListerID="" /> <Media runTime="04:03"/>
<SongURL></SongURL>
<SongBarCode></SongBarCode>
<SongCDKey></SongCDKey>
</Song>
<Song title="Sweet Nothing PLAY !!!!">
<Artist name="Calvin Harris with Florance Welsh" ID="" URL=""/>
<Info StartTime="03:45:32" JazlerID="5362" PlayListerID="" /> <Media runTime="03:26"/>
<SongURL></SongURL>
<SongBarCode></SongBarCode>
<SongCDKey></SongCDKey>
</Song>
<Song title="Somethin' Bad PLAY !!!!">
<Artist name="Foo Fighters" ID="" URL=""/>
<Info StartTime="03:48:58" JazlerID="3396" PlayListerID="" /> <Media runTime="02:26"/>
<SongURL></SongURL>
<SongBarCode></SongBarCode>
<SongCDKey></SongCDKey>
</Song>
<Song title="Tempted PLAY !!!">
<Artist name="Squeeze" ID="" URL=""/>
<Info StartTime="03:51:25" JazlerID="3835" PlayListerID="" /> <Media runTime="03:51"/>
<SongURL></SongURL>
<SongBarCode></SongBarCode>
<SongCDKey></SongCDKey>
</Song>
</Event>
You'll notice the text is in the tags instead of between them.

I will continue this post, got to go for now....
 
KNKL, this is well-formed XML, for which there is no other format/norm than W3C's. Any XML parser will be able to consume the document you posted. Are you having any specific difficulty in processing the document?
 
You see, the issue is the streaming encoders are designed for playing files instead of taking a live broadcast stream. So they don't accept the RDS (read out screen) data we send to the radio transmitter. So, I need to get data to shoutcast too as well as the web server instead of just making some javascript bandage on a site. It seems more logical to deliver the properly formatted html file while sending a shoutcast update using cUrl or something along those lines.

Besides that, this format (xml) seems a waste of time and I am glad this isn't a php page. Because I know of a couple of security flaws when they are combined in most web installs that compromise storage.

xml should just stay with the Microsoft operating system.

and quite frankly, all Microsoft technologies should be avoided at all cost, and every effort should be made to prevent using any of their products to create or use software much less build web technology with their xml language.


This badly written xml doesn't clean up efficiently with just some css. so you have to use a script, so its inefficient.

Its bad enough it has to waste electricity to regenerate itself to a different format (out at a server farm, or locally).
Its too bad the program can not be modified to add a SOAP routine that would give me the functions I really need.


I ran into a little snag installing cent os on that dell 4600 server, so I am going to try fedora since dell made redhat versions for enterprise web usage, as well as the SOHO version that was sold with windows 2003 server (which scott system used that version).

I guess these software companies must think the usb liscence key protects them (it doesn't). I've seen all of those microsoft programs that are broken. But maybe they cant program beyond something based off of MS Access. At least they did their house cleaning compared to ones that make dot net programs and just use the generic library instead of making one with gui objects they are only using. The worst thing that dot net did for the computing world was introduce sloppy programming habits.
 
KNKL,

Welcome to Tek-Tips.

We are here to help, but I would like to call attention to the tag line on the Tek-Tips logo (which you can see above), "INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS." So, here in Tek-Tips we tend to specialize so that we can give well-targeted advice. All this to say that most of your last post is off topic and probably not contributing to getting done the work you would like to do.

If we can focus instead on the following, which seems to be on-topic:
KNKL said:
It seems more logical to deliver the properly formatted html file

To do this (deliver in 'properly formatted' HTML) would be to violate one of the more basic rules of software development, that of separating data from user interface. It would seem that the XML document you show as an example is pure data. You expect to create a user interface using only CSS, but did you know that there is a fairly simple way to convert XML to HTML? This is another form of stylesheet known as XSLT, a language for transforming XML documents into HTML, plain text, or XML in another format. (One example of XML-to-XML translation is to transform XML data into XSL Formatting Objects which in turn can be used to create PDF, PostScript or PNG.)

And - good news - all of the tooling to create and execute XSL transforming stylesheets is available in open source, and is supported by all [major] browsers. So, for example, you can devise XSLT to transform the XML data to HTML and embed the reference to the XSLT stylesheet within the XML data before sending the data to the browser. With a bit of JavaScript, the browser will apply the transform on the client machine. (Of course, you can also do the transform on the server side, if that is more convenient. You seem to be using PHP, which typically installs with XSLT support on most Linux and Windows distributions.)

W3Schools has a useful tutorial here.

We really do stand ready to help you learn and put into practice state-of-the-art XML solutions. Simply try to keep posts on topic and focused on results.

One final, off-topic, observation: Microsoft has tended to be a follower rather than a leader in XML technologies.



Tom Morrison
Consultant
 
so what syntax you use for it?

because the examples have a differently formatted xml.
The example has "
XML:
<foo>BAR</foo>
" and mine looks like "
XML:
<foo myID="BAR"></foo>
"

in php, it would be
PHP:
$xml = simplexml_load_file("AirPlayNext.xml");
echo $xml->Event->Song->info->['JazlerID'];


to parse that "unconventional" format. (if my memory serves me right)
 
KNKL, there is nothing unconventional in using attributes in an XML document to store information.

XSLT uses XPath, a query language to select nodes of any type in an XML document. The XPath syntax to select an attribute node is [tt]@attribute_name[/tt] (which is the shorthand for [tt]attribute::attribute_name[/tt]). So, to get the attribute in [tt]<foo myID="bar">[/tt] one should use [tt]@myID[/tt] (the element name [tt]foo[/tt] may be or not required to be specified as well as any other segment of the DOM tree, depending on the execution context of the query).

Anyway, although not being anything close to the power of XSL Transformations, you can render your XML document in a browser using CSS2.

Your source document (notice the link to an external CSS), let's call it event.xml:
XML:
<?xml version="1.0" encoding="UTF-8"?>
[highlight #FCE94F]<?xml-stylesheet type="text/css" href="event.css"?>[/highlight]
<Event status="coming up">
  <Song title="Freeway Of Love">
    <Artist name="Aretha Franklin" ID="" URL=""/>
    <Info StartTime="03:35:36" JazlerID="1843" PlayListerID="" /> <Media runTime="05:44"/>
    <SongURL></SongURL>
    <SongBarCode></SongBarCode>
    <SongCDKey></SongCDKey>
  </Song>
  <Song title="All I Need Is A Miracle">
    <Artist name="Mike &amp; The Mechanics" ID="" URL=""/>
    <Info StartTime="03:41:20" JazlerID="2538" PlayListerID="" /> <Media runTime="04:03"/>
    <SongURL></SongURL>
    <SongBarCode></SongBarCode>
    <SongCDKey></SongCDKey>
  </Song>
  <Song title="Sweet Nothing PLAY !!!!">
    <Artist name="Calvin Harris with Florance Welsh" ID="" URL=""/>
    <Info StartTime="03:45:32" JazlerID="5362" PlayListerID="" /> <Media runTime="03:26"/>
    <SongURL></SongURL>
    <SongBarCode></SongBarCode>
    <SongCDKey></SongCDKey>
  </Song>
  <Song title="Somethin' Bad PLAY !!!!">
    <Artist name="Foo Fighters" ID="" URL=""/>
    <Info StartTime="03:48:58" JazlerID="3396" PlayListerID="" /> <Media runTime="02:26"/>
    <SongURL></SongURL>
    <SongBarCode></SongBarCode>
    <SongCDKey></SongCDKey>
  </Song>
  <Song title="Tempted PLAY !!!">
    <Artist name="Squeeze" ID="" URL=""/>
    <Info StartTime="03:51:25" JazlerID="3835" PlayListerID="" /> <Media runTime="03:51"/>
    <SongURL></SongURL>
    <SongBarCode></SongBarCode>
    <SongCDKey></SongCDKey>
  </Song>
</Event>

An external CSS document, named event.css to be placed next to the source XML document:
CSS:
Event, Song {display: block;}
Artist, Info, Media {display: inline}

Event:before {font-size: 1.5em; font-weight: bold; content: "Events " attr(status);}

Song:before {font-style: italic; content: attr(title)}
Song {margin-left: 1em; margin-top: 0.25em;}

Artist:before {content: " by "}
Artist:after {font-weight: bold; content: attr(name)}

Info[StartTime]:before {content: " starting at " attr(StartTime)}
Media[runTime]:before {content: " for " attr(runTime)}

When rendering event.xml in a browser, something like this will be shown:
Clipboard01_wbdjej.png
 
Thank you @altopes for showing me attr() css. Looks like there is a lot of css stuff came out after 1995 I need to look at. I'm using bootstrap css on the site. There is some pretty cool things (as far as transformations) that people can use. I know why some people don't like javascript, but isn't jquery just another flavor ? As they both execute on the user's machine? Its almost seems like jquery is a combination of css and javascript.

update: I got the old del poweredge 4600 to accept Ubuntu as the os in scsi mode. Will set up the rest of the drives by lvm methods. Kind of interesting for me that I have to work on these old Dells. I worked at the factory that assembled all those motherboards and cards. It took me a while to remember some of the "quirks" that was baked into these, like the cheap single chip solution that was a first for the industry, but it doesn't bus master in raid mode, which is what I forgot and its not documented very well. So if anyone on the web that is trying to boot a total raid with this, they have to provision a boot sector to do it (windows will do it auto Automatically with f5 "load additional drivers" ) but I don't recommend using the raid for a real time os like linux because of the timing. In Microsoft, they slowed down the driver to try to mitigate hardware timing issues (that causes blue screen crashes). The linux driver has the original timing profile. So sometimes, it would not be finished shifting data out of the controller and a new packet would force the data to be reset at the controller ic and the effect of it not competing the previous data packet would halt the slave clock in the controller.

Ok, back on topic so I can use css for this. This is one half of the battle, the other half would be sending the shoutcast update, which would be probably better to do that at the station.

the url I have to send:
Code:
[URL unfurl="true"]http://location_of_the_dnas.com/admin.cgi?sid=xx&password=base64password&mode=updateinfo&song=text_that_I_want_to_display[/URL]

For the guy who is setting this up for the station your password is YWRtaW46 plus your password in base64. So if the password was example, the base64 of it would be ZXhhbXBsZQ==. So the url formatted password would be: password=YWRtaW46ZXhhbXBsZQ== a good place for generating the base 64 password is for further reading see
 
ok, here is my script for the site. I used jquery to remove the css of the player to customize it. I'm still playing with css formatting, as I am going to scroll the tracks played and tracks coming up on desktops, but stationary on phones, so the css is just for the large device width.

but here is my script:
Code:
<script>
$(document).ready(function(){
    $("button.bb").click(function(){
$('link[rel=stylesheet][href~="[URL unfurl="true"]https://control.internet-radio.com:2199/jplayer/skin/blue.monday/css/jplayer.blue.monday.css"[/URL]]').remove();
        });
var auto_refresh = setInterval(function() {loadCurrentTrackId(); }, 15000); 
});

function loadCurrentTrackId() {
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {

    if (this.readyState == 4 && this.status == 200) {
var oldtrk="";
var tsttrk="";
var oldtrk = document.getElementById('trackNowId').innerHTML;
var tsttrk= this.responseText;   
 if (oldtrk != tsttrk){
 document.getElementById('trackNowId').innerHTML = tsttrk;
loadXMLDoc();
}
    }
  };
  xhr.open("GET", "trackid.php"+ ((/\?/).test("trackid.php") ? "&" : "?") + (new Date()).getTime());
  xhr.setRequestHeader( 'CacheControl', false );
  xhr.send();

}
function loadXMLDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById('innn').innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "customexportfile.htm"+ ((/\?/).test("customexportfile.htm") ? "&" : "?") + (new Date()).getTime());
  xhttp.setRequestHeader( 'CacheControl', false );
  xhttp.send();
  var xhtp = new XMLHttpRequest();
  xhtp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById('ntn').innerHTML = this.responseText;
    }
  };
  xhtp.open("GET", "AirPlayNext.xml"+ ((/\?/).test("AirPlayNext.xml") ? "&" : "?") + (new Date()).getTime());
  xhtp.setRequestHeader( 'CacheControl', false );
  xhtp.send();
 var xhp = new XMLHttpRequest();
  xhp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById('hist').innerHTML = this.responseText;
    }
  };
  xhp.open("GET", "AirPlayHistory.xml"+ ((/\?/).test("AirPlayHistory.xml") ? "&" : "?") + (new Date()).getTime());
  xhp.setRequestHeader( 'CacheControl', false );
  xhp.send();
}
</script>

this load at the start of the page by:
Code:
<body id="page-top" onload="setTimeout('goclear()', 2000);">
I time delayed this so that the previos jquery and css routines are over, as well as wait for the external css file I remove (from the player plugin).
The current song id is temporarily stored in a hidden html element it is first loaded on the 2 second delay, then every 15 seconds afterwards, it checks to see if the id number is different than the current song, then if it is different, then it updates the tracks played and tracks coming up elements. When I send via xhr/xttp, I attach the unix time on the get array to force the browsers not to cache it.

The php code (trackid.php) is a simple built in query that gets the id of the current songs xml file that gets uploaded:
Code:
<?php
$xml = simplexml_load_file("NowOnAir.xml");
echo $xml->Event->Song->Jazler['ID'];
?>
my css I put in the page:
Code:
Event, Song, Artist {display: block; font-size:95%;}



Song:before {font-style: italic; content: attr(title)}
Event, Song {vertical-align: super; margin-left: 1em; margin-top: 1.5em; align:left;}

Artist:before {

margin-left: 1em;
text-align:right;
 -moz-text-align-last:right; 
 text-align-last:right; content: "  by :  "}
Artist:after {font-weight: bold; content: attr(name); text-align:right; }

.marqueee {
 height: 33%;	
 overflow: hidden;
 position: relative;
}
Event{
background-color:#efefef;
 /* Starting position */
 -moz-transform:translateY(100%);
 -webkit-transform:translateY(100%);	
 transform:translateY(100%);
 /* Apply animation to this element */	
 -moz-animation: marqueee 20s linear infinite;
 -webkit-animation: marqueee 20s linear infinite;
 animation: marqueee 20s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes marqueee {
 0%   { -moz-transform: translateY(100%); }
 100% { -moz-transform: translateY(-100%); }
}
@-webkit-keyframes marqueee {
 0%   { -webkit-transform: translateY(100%); }
 100% { -webkit-transform: translateY(-100%); }
}
@keyframes marqueee {
 0%   { 
 -moz-transform: translateY(100%); /* Firefox bug fix */
 -webkit-transform: translateY(100%); /* Firefox bug fix */
 transform: translateY(100%); 		
 }
 100% { 
 -moz-transform: translateY(-100%); /* Firefox bug fix */
 -webkit-transform: translateY(-100%); /* Firefox bug fix */
 transform: translateY(-100%); 
 }
}
Formatting is a little bit awkward compared to plain html. There are some limitations to working with this type of formatted xml, but I'm figuring out what I can do with it....

attached is the web page.
edit: don't know where it went?!? I attached it. but i don't see it.
 
the only drawback is that "content" css does not work in internet explorer 11.

Which is why it was discouraged to use that formatting.

By the way it looks out there, the other xml format of the data between tags is preferred because of backwards compatibility.

so
Code:
 <artist>Bon Jovi</artist>
is a better format than
Code:
 <artist band="Bon Jovi" album="newest hits" ></artist>
because of compatibility..
 
I might use this php code instead. Because it get rid of the non-standard tags, and formats it in standard html:

Code:
<?php
$xml = simplexml_load_file("AirPlayHistory.xml");
echo '<table id="histtbl" >';
foreach($xml->Song as $Song)
{
    echo '<tr><td id="song">'.(string)$Song['title'].'</td><td id="by"> by: </td>';
    echo '<td id="artist">'.(string)$Song->Artist['name'].'</td>';
    echo "</tr>";
}
echo "</table>";
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top