Skip to content

Instantly share code, notes, and snippets.

@vrdriver
Last active April 5, 2019 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrdriver/ddc0ba5cd248098febc560b5ceb1b70b to your computer and use it in GitHub Desktop.
Save vrdriver/ddc0ba5cd248098febc560b5ceb1b70b to your computer and use it in GitHub Desktop.
Processing RCS XML
To process the following Billboard XML from the RCS Zetta radio playout system (as outputted through a MC v15 XML schema
using glue) in PHP, I do a conversion trick to make it actually usable in the XML processor.
Firstly, I pre-process all of the XML like this:
// dirty hack to fix the naming of xml fields.
$rawXML = str_replace("l:Link", "l_Link", $rawXML);
$rawXML = str_replace("s:Album", "s_Album", $rawXML);
$rawXML = str_replace("s:Song", "s_Song", $rawXML);
$rawXML = str_replace("t:Spot", "t_Spot", $rawXML);
$rawXML = str_replace("p:Sponsor", "p_Sponsor", $rawXML);
$rawXML = str_replace("w:WebPage", "w_WebPage", $rawXML);
$rawXML = str_replace("m:Media", "m_Media", $rawXML);
$rawXML = str_replace("s:SongAdditional", "s_SongAdditional", $rawXML);
$rawXML = str_replace("s:Artist", "s_Artist", $rawXML);
Then, after that, we run it through SimpleXMLElement, so it can be interpretted properly.
$xml = new SimpleXMLElement($rawXML);
The raw XML example:
<?xml version="1.0" encoding="UTF-8"?>
<CueList xmlns="urn:CueListSchema.xml" time="2019-04-05T09:53:15">
<Event eventID="4072709" eventType="song" status="happening" scheduledTime="09:53:12" scheduledDuration="207.20" segue="xFade" failureCode="0" editCode="0">
<s:Song xmlns:s="urn:schemas-rcsworks-com:SongSchema" ID="325403" title="DEEPER LOVE" category="B1">
<s:Artist name="LANDRY CANTRELL" />
<s:Album title="PROJECTIONS" />
<m:Media xmlns:m="urn:schemas-rcsworks-com:MediaSchema" ID="" runTime="207.20" fileName="" />
</s:Song>
</Event>
<Event eventID="4072710" eventType="link" status="committed" startTime="09:56:19" actualDateTime="2019-04-05T09:56:19" scheduledDuration="1.93" segue="linkSong" failureCode="0" editCode="0">
<l:Link xmlns:l="urn:schemas-rcsworks-com:LinkSchema" ID="135331" title="ID - V180 Primary Positioner (Cold) 12 " category="id2">
<m:Media xmlns:m="urn:schemas-rcsworks-com:MediaSchema" ID="" runTime="1.93" fileName="" />
</l:Link>
</Event>
<Event eventID="4072711" eventType="song" status="committed" startTime="09:56:21" actualDateTime="2019-04-05T09:56:21" scheduledDuration="215.43" segue="xFade" failureCode="0" editCode="0">
<s:Song xmlns:s="urn:schemas-rcsworks-com:SongSchema" ID="131711" title="GOOD NEWS" category="G1">
<s:Artist name="MANIC DRIVE" />
<s:Album title="V.I.P" />
<m:Media xmlns:m="urn:schemas-rcsworks-com:MediaSchema" ID="" runTime="215.43" fileName="" />
</s:Song>
</Event>
</CueList>
Without going it to too much detail, this is a summary of how to get the data out:
if ($xml->Event['status'] == "happening")
{
if (isset($xml->Event[0]->s_Song['title'])) // Songs only
{
$EntityType=1;
$NP_CTitle = trim(cleanQuery($dbh, $xml->Event[0]->s_Song['title']));
$NP_PNName = trim(cleanQuery($dbh, $xml->Event[0]->s_Song->s_Artist['name']));
$NP_SATitle = trim(cleanQuery($dbh, $xml->Event[0]->s_Song->s_Album['title']));
$RCSSongID = cleanQuery($dbh, $xml->Event[0]->s_Song['ID']);
$RCSSongCat = cleanQuery($dbh, $xml->Event[0]->s_Song['category']);
$RCSSongLev = cleanQuery($dbh, $xml->Event[0]->s_Song['level']);
}
// The double makes sure that we don't get voice tracks and others coming in
if (isset($xml->Event[0]->l_Link['title']) && isset($xml->Event[0]->l_Link['category']))
{
// Links
$EntityType=2;
$NP_CTitle = trim(cleanQuery($dbh, $xml->Event[0]->l_Link['title']));
$NP_PNName = cleanQuery($dbh, $xml->Event[0]->l_Link['category']); // Yes, this is set as the category, so that it can be pulled out and fixed later
$RCSSongID = cleanQuery($dbh, $xml->Event[0]->l_Link['ID']);
$RCSSongCat = cleanQuery($dbh, $xml->Event[0]->l_Link['category']);
// Added to prevent Zetta Problems with Category names
$NP_SATitle = trim(cleanQuery($dbh,$xml->Event[0]->l_Link['title']));
}
}
You can figure out the rest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment