Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xml parsing

54 views
Skip to first unread message

Sverre Bakke

unread,
Apr 22, 2003, 6:40:29 PM4/22/03
to
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?


David Bigelow

unread,
Apr 22, 2003, 10:37:44 PM4/22/03
to
> 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 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

Michael A. Cleverly

unread,
Apr 22, 2003, 10:42:41 PM4/22/03
to
On 22 Apr 2003, David Bigelow wrote:

> > 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

Cameron Laird

unread,
Apr 23, 2003, 1:09:53 PM4/23/03
to
In article <Pine.LNX.4.44.030422...@gibraltar.cleverly.com>,

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

Steve Ball

unread,
Apr 27, 2003, 8:09:39 PM4/27/03
to
Cameron Laird wrote:
>>On 22 Apr 2003, David Bigelow wrote:
>>>>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?
[...snip...]

> 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.

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

Michael A. Cleverly

unread,
Jun 2, 2003, 10:44:03 PM6/2/03
to
On Wed, 23 Apr 2003, Cameron Laird wrote:

> 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

Ryan Casey

unread,
Jun 4, 2003, 12:29:10 AM6/4/03
to
"Michael A. Cleverly" <mic...@cleverly.com> wrote in message news:<Pine.LNX.4.44.030602...@gibraltar.cleverly.com>...

> On Wed, 23 Apr 2003, Cameron Laird wrote:
> I started a new page on the wiki last week: "A tDOM Tutorial".
> http://wiki.tcl.tk/8984


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

unread,
Jun 4, 2003, 12:25:07 PM6/4/03
to
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.

--
Luciano ES
<luci...@ggmmxx.nneett>
Santos, SP - Brasil

<-quote-> **************************************************

Michael A. Cleverly

unread,
Jun 4, 2003, 2:37:28 PM6/4/03
to
On 4 Jun 2003, Luciano wrote:

> 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

Michael A. Cleverly

unread,
Jun 4, 2003, 3:00:20 PM6/4/03
to
On 3 Jun 2003, Ryan Casey wrote:

> 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


Luciano

unread,
Jun 4, 2003, 3:22:12 PM6/4/03
to
Sure, I found it and forgot to come here and tell you.

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 Schlenker

unread,
Jun 4, 2003, 4:43:12 PM6/4/03
to
Luciano wrote:
> 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

Michael Schlenker

unread,
Jun 4, 2003, 4:46:26 PM6/4/03
to
Luciano wrote:
> Sure, I found it and forgot to come here and tell you.
>
> 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.
XML isn't that fast usually, did you try the dom model or a the sax like
parsing style? (tdom is quite a fast xml-dom system btw, compared to the
java stuff)

Michael

0 new messages