For the Download - Use the "http" pacakge - that is also very easy to
use, and you can do just about everything in a couple of lines of code
for the downloading.
For the XML Parsing - The already supported and distributed TclXML
will do this "perfectly", and with minor programming using the TclXML
lib you can do literally anything you want very quickly... (examples
are in the man pages and also on this discussion thread)
BTW - If you are working with SOAP - Tcl/TK 8.4.2 is probably your
best bet for using this method of client/server communication. I have
not tested it yet (still running 8.4.1 due to some customer support
issues) - but I hear it works.
Hope this helps... and Good Luck!
Dave
> > I need to make my tcl script download a xml document from a http server and
> > parse it...does anyone know about a good tcl -> xml tutorial?
>
> For the XML Parsing - The already supported and distributed TclXML
> will do this "perfectly", and with minor programming using the TclXML
> lib you can do literally anything you want very quickly... (examples
> are in the man pages and also on this discussion thread)
I've found tDOM much easier to build & use than TclXML. YMMV. See:
http://www.tdom.org
Michael
What *do* we have to offer in the way of "tutorials", though?
<URL: http://wiki.tcl.tk/8794 > is as far as I've been able
to get.
--
Cameron Laird <Cam...@Lairds.com>
Business: http://www.Phaseit.net
Personal: http://phaseit.net/claird/home.html
My company, Zveno, has training courses on TclXML, TclDOM and
TclXSLT. These are the tutorials that have been presented at
Tcl Conferences in the past few years.
I am working towards offering these tutorials as free samples
on our website: http://www.zveno.com/. Haven't quite completed
all of the work required to get the materials available
(too much paying work getting in the way... sigh).
Some folks have purchased the course materials directly;
send me an email if you're interested.
Alternatively I am perfectly happy to include contributed
examples/tutorials on the TclXML website: http://tclxml.sf.net/
Cheers,
Steve Ball
--
Steve Ball | XSLT Standard Library | Training & Seminars
Zveno Pty Ltd | Web Tcl Complete | XML XSL Schemas
http://www.zveno.com/ | TclXML TclDOM | Tcl, Web Development
Steve...@zveno.com +---------------------------+---------------------
Ph. +61 2 6242 4099 | Mobile (0413) 594 462 | Fax +61 2 6242 4099
> What *do* we have to offer in the way of "tutorials", though?
> <URL: http://wiki.tcl.tk/8794 > is as far as I've been able
> to get.
I started a new page on the wiki last week: "A tDOM Tutorial".
http://wiki.tcl.tk/8984
Michael
THANK YOU! That was great for me. I was attempting to glean this
knowledge from the docs and it just wasn't coming.
I am trying to work with some custom XML, and I forgot to enclose my
set of items with one encompassing tag, which tDOM choked on. Once I
figured that out, I downloaded Kitten and StarDOM and everything
loaded fine, and I am working on the tDOM code for my application.
I am having some issues with the XPath searching. I always get all
the nodes with particular path, and I don't see how to limit that.
For instance, I want to get Item 2's title, but it might not always be
[lindex 1]. I am going back to tDOM's docs to look for this, but I
thought someone might know here.
<items>
<item id='1'>
<title>Item 1</title>
</item>
<item id='2'>
<title>Item 2</title>
</item>
</items>
Ryan P. Casey
--
Luciano ES
<luci...@ggmmxx.nneett>
Santos, SP - Brasil
<-quote-> **************************************************
> Michael, could you tell me where you get that "tdom" package? I have
> Tcl/Tk 8.4.3 and it says there is no "tdom" package. I've been unable
> to make any of that work.
http://www.tdom.org has both source & binary downloads for Linux &
Windows. There are also links to a version packaged as a star kit and
binaries for Mac OS 8/9 & OS X.
Michael
> I am having some issues with the XPath searching. I always get all
> the nodes with particular path, and I don't see how to limit that.
> For instance, I want to get Item 2's title, but it might not always be
> [lindex 1]. I am going back to tDOM's docs to look for this, but I
> thought someone might know here.
The tDOM node selectNode method takes an xpath expression, which can
contain be crafted to constrain the results. I haven't found a really
good concise xpath tutorial/reference online yet. What I know about xpath
has largely been through trial & error :-).
Both of these xpath expressions will get you the text node of the title of
the 2nd item directly:
set node [$root selectNodes {/items/item[2]/title/text()}]
set node [$root selectNodes {/items/item[@id='2']/title/text()}]
The first essentially says: get the text node of the title tag which is
the child of the 2nd instance of <item> under <items>.
The second says: the the text node of the title tag whose parent is an
item tag with an attribute of id which is equal to 2 and is also a child
of <items>.
> <items>
> <item id='1'>
> <title>Item 1</title>
> </item>
> <item id='2'>
> <title>Item 2</title>
> </item>
> </items>
Michael
I ran a few tests and thought it is a little slow... I was parsing
XML with RE and it was slow. The XML parser is a little faster, but
nothing to get hip about.
--
Luciano ES
<luci...@ggmmxx.nneett>
Santos, SP - Brasil
<-quote-> **************************************************
Michael