Save XML files in CCG by using DATA STORE

Hello again,

okay, I have the following idea:
I’d like to store data with a client and use the same data with another client via network.
So my idea was to generate an XML file and store it in CCG using DATA STORE.

So I serialized the XML into a string and try to send it.

At the first attempt DATA STORE only saved the first word /<xml. So I replaced every CRLF with an “;”. Result: no real approvement.

While experimenting I noticed that every time a SPACE sign occurs in the text the data storage ends.
That is happening as well when I try to save a single line. “Thomas Mueller” is saved as “Thomas” only.

Any ideas or suggestions about that?

Thanks!

Ingo

It would be more helpful to see your actual commands. I’m guessing that the data isn’t in quotes.

Hi hreinnbeck,

here is the code for XML:

   Function xml_serialize(ByVal obj As Object) As String
        Dim serializer As New Serialization.XmlSerializer(obj.GetType)
        Dim s As String

        Dim ms As New MemoryStream()
        serializer.Serialize(ms, obj)

        ' --- Stream in String umwandeln
        Dim r As StreamReader = New StreamReader(ms)
        r.BaseStream.Seek(0, SeekOrigin.Begin)
        s = r.ReadToEnd

        Return s
    End Function

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim xml As XmlDocument = CollectSnapData()
        CasparDevice.SendString("DATA STORE TEST " & xml_serialize(xml).Replace(vbCrLf, ";"))
    End Sub

whereas “CollectSnapData” is a Function that produces a XML looking like

<?xml version="1.0" encoding="UTF-8"?>
<ChannelData Erzeugt="30.06.2020 08:13:19">
  <Channel_1>
    <MediaFile>EBU/01_01</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_1>
  <Channel_2>
    <MediaFile>CASTLES720</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_2>
  <Channel_3>
    <MediaFile>EBU/01_03</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_3>
  <Channel_4>
    <MediaFile>EBU/01_04</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_4>
  <Channel_5>
    <MediaFile>EBU/05_01</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_5>
  <Channel_6>
    <MediaFile>EBU/04_01</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_6>
  <Channel_7>
    <MediaFile>EBU/05_03</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_7>
  <Channel_8>
    <MediaFile>EBU/05_05</MediaFile>
    <Loop>True</Loop>
    <Trans>25</Trans>
  </Channel_8>
</ChannelData>

Ingo

Yeah that code doesn’t look like it’s quoting the data. Are you using the libdotnet library? Then you should probably use something like CasparDevice.StoreData('TEST', xml)

Thanks hreinnbeck,

That seems to be the solution.

I’ll check the details later when I returned from my upcoming meeting.

Thanks!

Ingo

That makes the XML invalid. You can simply remove the CRLF or keep them, that does not make a difference.

To send the XML via DATA STORE (and also with CG ADD) all quotes " needs to be replaced by \" (escaped) and then the whole XML needs to be enclosed in with (unescaped) ". Without the escaping of the quotes, Caspar will interpret the second quote it finds as the end of the data.

Hi didi and hrreinbeck,

Thanks for your input. You’re right: Spoiling the XML-file dosen’t lead to a proper outcome :grinning:
However hrreinbecks solution works for me with some modifications.

Thank you both

Ingo