0

XML child objects

Hi,
having issues to resolve <startdate> and <enddate> from my event-XML.

My XMLfeed is generated by Wordpress and the "theeventscalendar" plugin.
(https://theeventscalendar.com/)

<startdate> and <enddate> are childnodes in the xml, but after trying all normal scripting-things, i still can't distillate them.

 

<item>
<title>Event</title>
<link>https://server/agenda/events/</link>
<comments>https://server/agenda/events/someevent</comments>
<pubDate>Thu, 31 Jan 2019 07:00:00 +0000</pubDate>
<dc:creator><![CDATA[admin]]></dc:creator>

<guid isPermaLink="false">https://server/agenda/events/someevent</guid>
<description><![CDATA[big party]]></description>
<content:encoded><![CDATA[<p>there is a big party</p>]]></content:encoded>
<wfw:commentRss>https://server/agenda/events/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>

<ev:tribe_event_meta xmlns:ev="Event">
<ev:startdate>31 january | 08:00</ev:startdate>
<ev:enddate>31 january | 17:00</ev:enddate>
</ev:tribe_event_meta>
</item>

3 comments

  • 0
    Avatar
    Lyndon

     

    In the code below where I wrap your item inside a standard rss feed, I can get to your dates using the following. THere's a date.gettext() call for both the start date entry and end date entry.  IN this example, I'm just printing them out...

    xml = CreateObject("roXMLElement")
    if not xml.Parse(ReadAsciiFile(xmlFileName$)) then
    print "xml read failed"
    else
    if type(xml.channel.item) = "roXMLList" then
    index% = 0
    for each itemXML in xml.channel.item
    'itemsByIndex.push(itemXML.title.GetText())

    allItemChildren = itemxml.GetChildELements()

    for each child in allItemChildren
    if child.getname() = "ev:tribe_event_meta" then
    dateslist = child.getChildElements()

    For each date in dateslist
    if date.getname() = "ev:startdate" then print date.gettext()
    if date.getname() = "ev:enddate" then print date.gettext()
    next
    endif
    next


    index% = index%+1
    next
    endif
    endif

     

  • 0
    Avatar
    Johan Westerlaken

    Dear Lyndon,
    Thanks for your script-hints.

    Took your script step-by-step to get the correct data out.

    Works fine!

  • 0
    Avatar
    Evan Wong

    may i ask what about retrieving data from within the tag, say in openweather's xml, if you want to get temperature from:

    <current>
        <city id="2643741" name="City of London">
         <coord lon="-0.09" lat="51.51">
         <country>GB</country>
         <sun rise="2015-06-30T03:46:57" set="2015-06-30T20:21:12">
        </city>
        <temperature value="72.34" min="66.2" max="79.88" unit="fahrenheit"/>
        <humidity value="43" unit="%">
        <pressure value="1020" unit="hPa">
        <wind>
         <speed value="7.78" name="Moderate breeze">
         <direction value="140" code="SE" name="SouthEast">
        </wind>
        <clouds value="0" name="clear sky">
        <visibility value="10000">
        <precipitation mode="no">
        <weather number="800" value="Sky is Clear" icon="01d">
        <lastupdate value="2015-06-30T08:36:14">
    </current>

    please give me a hint, been trying to search for an example for days. Thanks alot.

Please sign in to leave a comment.