XML help
Monte Goulding
monte at sweattechnologies.com
Wed Dec 19 01:42:24 EST 2012
On 19/12/2012, at 4:55 PM, Gerry Orkin wrote:
> Hi all
>
> I have no XML experience and I need help with extracting data from a tree. Hope someone can point me in the right direction - I've looked at the XML lesson on the RunRev site but I can't transfer what I've learnt there to my situation for some reason (well, the reason is I'm new to this and confused :)).
>
> Here's my XML:
>
>
> <item>
> <title>The XYZ Podcast: Episode #291</title>
> <pubDate>Thu, 06 Dec 2012 15:30:57 +0000</pubDate>
> <guid isPermaLink="false"><![CDATA[8282b5a5e0aaf2f2c1b8407ca813deb3]]></guid>
> <link><![CDATA[http://XYZpodcast.com/the-XYZ-podcast-episode-291]]></link>
> <media:thumbnail url="http://assets.libsyn.com/item/2148560" />
> <description>Some show notes go here</description>
> <enclosure length="57854477" type="audio/mpeg" url="http://traffic.libsyn.com/XYZpodcast/XYZPodcast291-Dec06-12.mp3" />
> </item>
> <item>
> <title>The XYZ Podcast: Episode #292</title>
> <pubDate>Thu, 06 Dec 2012 15:30:57 +0000</pubDate>
> <guid isPermaLink="false"><![CDATA[8282b5a5e0aaf2f2c1b8407ca813deb3]]></guid>
> <link><![CDATA[http://XYZpodcast.com/the-XYZ-podcast-episode-292]]></link>
> <media:thumbnail url="http://assets.libsyn.com/item/2148560" />
> <description>Some show notes go here</description>
> <enclosure length="43852797" type="audio/mpeg" url="http://traffic.libsyn.com/XYZpodcast/XYZPodcast291-Dec20-12.mp3" />
> </item>
>
> (That goes on for 322 items!)
>
> There is other, non-repeating stuff at the top of the feed that I've not pasted here, and I can get the contents of those nodes with no problem at all. But how do I then extract all the sub-nodes under the <item> node into a table?
Does your list of items have a parent node? Odd if it doesn't.
I'm guessing it does so you can do something like this:
put 1 into tIndex
repeat for each line tNode in revXMLChildNames(treeID,"/items",cr,"item",true)
repeat for each line tChildNode in revXMLChildNames(treeID,"/items/"&tNode,cr,,false)
put revXMLNodeContents(treeID,"/items/"&tNode&"/"&tChildNode) into tData[tIndex][tChildNode]
end repeat
add 1 to tIndex
end repeat
>
> Thanks in advance!
>
> Gerry
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
--
M E R Goulding
Software development services
Bespoke application development for vertical markets
mergExt - There's an external for that!
More information about the use-livecode
mailing list