December 07, 2019, 09:21:42 PM
Welcome, Guest. Please login or register
News: Join us for a FREE Webinar this Thursday at http://webinar.digitalsignage.com

MediaSignage support forum



Author Topic: XML Components: reading the element text vs. a field value  (Read 2305 times)

solerous

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
XML Components: reading the element text vs. a field value
« on: July 30, 2013, 12:32:45 PM »
I watched the XML video but I was wondering how to get at the data inside an element tag's opening and closing brackets vs. the data in a field tag. Here's what I mean. If this were my file:

<?xml version="1.0" encoding='UTF-8'?>

<myfile>

<ticker>
<arg1>I'm not using this</arg1>
<arg2>It will be read in a different component</arg2>
</ticker>

<mydata>

<row id="1">
<column1>This is the data I care about</column1>
<column2>Blah Blah Blah</column2>
<column3>Blah Blah Blah</column3>
</row>

<row id="2">
<column1>Blah Blah Blah</column1>
<column2>Blah Blah Blah</column2>
<column3>Blah Blah Blah</column3>
</row>

</mydata>

</myfile>

How would I get at all of the column data (all the "Blah Blah Blah" statements)? Is there even a way to get at something that isn't a field?

Thanks?

AndrewL

  • Full Member
  • ***
  • Posts: 130
  • Karma: +6/-0
    • View Profile
Re: XML Components: reading the element text vs. a field value
« Reply #1 on: July 30, 2013, 07:20:48 PM »
Hey Solerous

This is the configuration I use.

To have an XML file that displays a specific item within the XML file use this example:

Code: [Select]
<XmlTest source="my feed name">
<Board seq="1" field1="Have you tried our Yoga Class? " field2="Ask us how it can help you! " field3="" field4="" field5="" field6=""/>
<Board seq="2" field1="Watch for our new expansion! " field2="Ask us for more details! " field3="" field4="" field5="" field6=""/>
<Board seq="3" field1="Got Pain? GET RELIEF! " field2="Call Mark today!  " field3="" field4="" field5="" field6=""/>
</XmlTest>

Then in the XML Player on the timeline make the Items Path
Code: [Select]
Board.(@seq=="1")In the XML Item in your scene make the Field name @field1 then another one as @field2 and so on.

To show the content for seq 2 just make the Items Path in a duplicate or new scene
Code: [Select]
Board.(@seq=="2") and so on.

To have an XML file that slide shows in order just make sure the seq in each line are the same and check box the slideshow in the studio.
Code: [Select]
<XmlTest source="my feed name">
<Board seq="1" field1="Have you tried our Yoga Class? " field2="Ask us how it can help you! " field3="" field4="" field5="" field6=""/>
<Board seq="1" field1="Watch for our new expansion! " field2="Ask us for more details! " field3="" field4="" field5="" field6=""/>
<Board seq="1" field1="Got Pain? GET RELIEF! " field2="Call Mark today!  " field3="" field4="" field5="" field6=""/>
</XmlTest>

Hope this helps you out.

Andrew

solerous

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: XML Components: reading the element text vs. a field value
« Reply #2 on: July 31, 2013, 07:25:06 AM »
Andrew, thanks for the reply. Yes, I've been able to get it working that way, which utilizes fields. I was just hoping to get at the text in an element tag instead, i.e. with this tag:

<foo field1="something">Text I care about</foo>

I want to access the "Text I care about" vs. the "something".

The more I think about it, there just might not be a way for MediaSignage to access this. I hope I'm wrong though because this XML file I'm working with is generated by a piece of software and I don't want to have to re-write it if possible.

criley

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 598
  • Karma: +15/-0
    • View Profile
Re: XML Components: reading the element text vs. a field value
« Reply #3 on: July 31, 2013, 01:50:23 PM »
Don't use the @ symbol. This is for grabbing the Attribute. so you should be using Field name: foo. This will give you the text you are after.

solerous

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: XML Components: reading the element text vs. a field value
« Reply #4 on: August 01, 2013, 07:29:55 AM »
Awesome. Exactly what I was looking for. Thanks!

criley

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 598
  • Karma: +15/-0
    • View Profile
Re: XML Components: reading the element text vs. a field value
« Reply #5 on: August 01, 2013, 10:50:43 AM »
Anytime

 

Carbonate design by Bloc
variant: carbon
SMF 2.0.12 | SMF © 2016, Simple Machines