[REBOL] Re: XML-Parsing?!?
From: pscheller:atos:ch at: 25-Oct-2000 16:35
Hi Joel
First of all thank you very much for this intensiv reply. I still need
some time to read it all through.
Still, as I wrote Petr I have the simple need for a possibility to read
an external XML-File and extract values from certain tags like this:
Pseudo: print the value of Prozesse/cre
------------------------BEGIN XML----------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!-- Diese Datei enthält die Stati der xxx relevanten Prozesse -->
<!-- 0=OK, 1=Fehler/fehlend, 2=Unbekannt -->
<test1 name = "Patrick" />
<test2 name = "Scheller" />
<Prozesse>
<xxx = "1" />
<cre = "2" />
<ora = "3" />
<xxxrec = "4" />
<db_ppb = "5" />
</Prozesse>
<!-- Ende der Datei -->
-------------------------END XML-----------------------------------
Joel Neely wrote:
> Hi, Patrick,
>
> I've been playing with parse-xml for quite a while (in fact, that's
> what got me to using REBOL seriously in the first place), so let me
> give a couple of hints that may help.
> > I have the need to parse XML-Documents to form a HTML page from it. Now
> > with all the functions related to that I still was unable to extract any
> > tags value from a XML-file. I know I could do all the parsing on my own,
> > but I suspect that somehow Rebol could do this for me in a more
> > convenient way. Or am I wrong?
> Absolutely right! I do it all the time.
Glad to hear that :-)
> > Now if someone could explain me the concepts of these functions any
> > further. Or just tell me I'm completely wrong, I'm just stuck right
> > now.
> >
> > parse-xml: returns a block which should contain the tags and values
> >
>
> PARSE-XML takes a string and gives you back a structure of nested
> blocks that represents the XML structure in the string. A typical
> example is:
>
> >> foo: {<a>
> { <b>Hi, Patrick!</b>
> { <c type="demo" />
> { <d pos="last">
> { end
> { </d>
> { </a>}
> == {<a>
> <b>Hi, Patrick!</b>
> <c type="demo" />
> <d pos="last">
> end
> </d>
> </a>}
> >> fum: parse-xml foo
> == [document none [["a" none ["^/" ["b" none ["Hi, Patrick!"]] "^/"
> ["c" ["type" "demo"] none] "^/" ["d" ["pos" "last"] ["^/ end^/"...
....
Thanx again Joel "Live long and prosper" :-)
Greets to all, pat le cat