From: Richard Owlett on
http://wiki.tcl.tk/11020 provides most of what I'm looking for.
I have minimal experience with TCL and just getting my feet wet
with XML.

The data I'm attempting to parse comes from openstreetmap.org.
This exercise is _PRIMARILY_ for learning more of *TCL* and *XML*.

After looking at the output of the code at wiki.tcl.tk/11020, It
would appear straight forward to extract just the information of
interest (node lat/lon, nodes in a way).

My question. It appearing so straight forward makes me think
there should already be tools to extract related information from
an XML file. Is there? Am I on the right track?
From: George Petasis on
στις 29/1/2010 02:53, O/H Richard Owlett έγραψε:
> http://wiki.tcl.tk/11020 provides most of what I'm looking for.
> I have minimal experience with TCL and just getting my feet wet with XML.
>
> The data I'm attempting to parse comes from openstreetmap.org.
> This exercise is _PRIMARILY_ for learning more of *TCL* and *XML*.
>
> After looking at the output of the code at wiki.tcl.tk/11020, It would
> appear straight forward to extract just the information of interest
> (node lat/lon, nodes in a way).
>
> My question. It appearing so straight forward makes me think there
> should already be tools to extract related information from an XML file.
> Is there? Am I on the right track?

I think it is better to look ate tdom (http://wiki.tcl.tk/1948) or TclXML...

George
From: slebetman on
On Jan 29, 9:21 am, George Petasis <peta...(a)iit.demokritos.gr> wrote:
> στις 29/1/2010 02:53, O/H Richard Owlett έγραψε:
>
> >http://wiki.tcl.tk/11020provides most of what I'm looking for.
> > I have minimal experience with TCL and just getting my feet wet with XML.
>
> > The data I'm attempting to parse comes from openstreetmap.org.
> > This exercise is _PRIMARILY_ for learning more of *TCL* and *XML*.
>
> > After looking at the output of the code at wiki.tcl.tk/11020, It would
> > appear straight forward to extract just the information of interest
> > (node lat/lon, nodes in a way).
>
> > My question. It appearing so straight forward makes me think there
> > should already be tools to extract related information from an XML file..
> > Is there? Am I on the right track?
>
> I think it is better to look ate tdom (http://wiki.tcl.tk/1948) or TclXML....
>

I second tdom because it implements standard DOM methods like
getElementById and getElementsByTagName
From: MartinLemburg on
Hi,

I mostly use tdom, because it is for me more intuitive in its usage.

If it is about XML style sheets (transformations), than I use tdom,
because it is much easier to use.
If there is a need for a full XPaths Version 2.0 support, than you
would have to use TclXML/TclDOM.
If it is about using XML Schemes to validate XML files, than there is
no other way, than using TclXML/TclDOM, too.

Best regards,

Martin Lemburg

On 29 Jan., 01:53, Richard Owlett <rowl...(a)pcnetinc.com> wrote:
> http://wiki.tcl.tk/11020provides most of what I'm looking for.
> I have minimal experience with TCL and just getting my feet wet
> with XML.
>
> The data I'm attempting to parse comes from openstreetmap.org.
> This exercise is _PRIMARILY_ for learning more of *TCL* and *XML*.
>
> After looking at the output of the code at wiki.tcl.tk/11020, It
> would appear straight forward to extract just the information of
> interest (node lat/lon, nodes in a way).
>
> My question. It appearing so straight forward makes me think
> there should already be tools to extract related information from
> an XML file. Is there? Am I on the right track?

From: PaulWalton on
On Jan 28, 6:53 pm, Richard Owlett <rowl...(a)pcnetinc.com> wrote:
> http://wiki.tcl.tk/11020provides most of what I'm looking for.
> I have minimal experience with TCL and just getting my feet wet
> with XML.
>
> The data I'm attempting to parse comes from openstreetmap.org.
> This exercise is _PRIMARILY_ for learning more of *TCL* and *XML*.
>
> After looking at the output of the code at wiki.tcl.tk/11020, It
> would appear straight forward to extract just the information of
> interest (node lat/lon, nodes in a way).
>
> My question. It appearing so straight forward makes me think
> there should already be tools to extract related information from
> an XML file. Is there? Am I on the right track?

If you don't want to use a catch-all xml parser and you know what to
expect in the xml file, then you can write some code to parse out
exactly what you want. To me this is simpler and more reliable than
using an extension because the data might not be perfectly valid xml
or the parser might be imperfect.

set token [http::geturl "http://site.org/file.xml"]
set data [http::data $token]
http::cleanup $token


And if $data looks something like this:

<lattitude>30°12′50″N</lattitude>
<longitude>92°01′46″W</longitude>
<otherstuff>abc123</otherstuff>


Then you can do this:

set index [string first {<lattitude>}]
incr index 11
set end [string first {</lattitude>} $index]
incr end -1
set lattitude [string range $data $index $end]


You can also use regular expressions...
 |  Next  |  Last
Pages: 1 2 3
Prev: deleting error
Next: Off Topic -- Leukemia Fund raiser