Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Navigation in output produced by parse-xml

From: joel:neely:fedex at: 25-May-2001 12:57

Hi, again, James, The other reply was long enough, but I should point out that you can make things a little more readable by adding a spoonful of [syntactic] sugar to help the XML go down... ;-) James Carlyle wrote:
> I want to parse an XML document, find an element, and then > find some ancestors of that element... >
With the following definitions in place:
>> element-name: :first >> element-attributes: :second >> element-content: :third >> generations?: :length? >> current: :first >> parent: :second >> grandparent: :third
We can rewrite our last example as print-content: func [estack [block!]] [ print element-content current estack ] cell-in-row?: func [estack [block!]] [ all [ 2 <= generations? estack "cell" = element-name current estack "row" = element-name parent estack ] ]
>> walkxml data :cell-in-row? :print-content
A B C D E F ... in case that makes for more readability for someone who hasn't been playing with REBOL-style XML blocks for a year or two... ;-) -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com