Issue Parsing XML in live code, Insights appreciated.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
TrevorDowdle
Posts: 16
Joined: Tue Jul 10, 2012 4:37 pm

Issue Parsing XML in live code, Insights appreciated.

Post by TrevorDowdle » Tue Jul 10, 2012 4:49 pm

I am having an issue accessing all the date values in the following xml

<entries>
<entry>
<date>2011-08-18</date>
<name></name>
</entry>
<entry>
<date>2011-08-19</date>
<name></name>
</entry>
<entry>
<date>2011-08-20</date>
<name></name>
</entry>
</entries>

With the following code I am accessing just one of the date nodes but am having trouble getting the node contents for each date node.

Code: Select all

local tPosts
   put revXMLChildNames(pTree, "entries/entry", return, "date", true) into tPosts     
   local tListOfDates

   repeat for each line tDate in tPosts
      put revXMLNodeContents(pTree, "entries/entry/" & tDate) & return after tListOfDates
   end repeat
Appreciate any insight or help you can give me.

Thanks

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Issue Parsing XML in live code, Insights appreciated.

Post by mwieder » Tue Jul 10, 2012 5:19 pm

I think you're drilling down too deep to start with. Try this

Code: Select all

    put revXMLChildNames(pTree, "entries" , return, , true) into tPosts
    repeat for each line tEntry in tPosts
        put revXMLNodeContents(pTree, "entries/" & tEntry & "/date" ) & return after tListOfDates
    end repeat

TrevorDowdle
Posts: 16
Joined: Tue Jul 10, 2012 4:37 pm

Re: Issue Parsing XML in live code, Insights appreciated.

Post by TrevorDowdle » Tue Jul 10, 2012 5:35 pm

That did it!


Thanks

Post Reply