ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tclxml-users
tclxml-users
[Tclxml-users] newbie basic question using parser to extract Tag names and characterdata together...
by Anthony G other posts by this author
Jan 31 2007 3:33PM messages near this date
[Tclxml-users] basic XPATH Query how to question | Re: [Tclxml-users] newbie basic question using parser to extract Tag names and characterdata together...
Hello TCLXML experts :)

I have been searching for a few days online for tutorials on how to use
TCLXML and I have a very basic task.  I want to be able to take an xml file
say like this

<MY_STRUCTURE> 
 <TAG2>  tag2 data </TAG2>
 <TAG3>  tag3 data </TAG3>
 <TAG4> 
   <TAG5>  tag5 data </TAG5>
   <TAG6>  tag6 data </TAG6>
 </TAG4> 
</MY_STRUCTURE> 

and export the data above into a data structure, say a list or maybe even a
hastable (TCL ARRAY)

for example I would want to create an array

MYSTRUCTURE

with the index's based on the TAGS that fall under it example

set MYSTRUCTURE(TAG2) "tag2 data"
set MYSTRUCTURE(TAG3) "tag3 data"
set MYSTRUCTURE(TAG4,TAG5) "tag5 data"
set MYSTRUCTURE(TAG4,TAG6) "tag6 data"

or something like this... where the index indicates level...

what I have seen so far is that I can use the xml::parser to pull out tags
and data, but none at the same time...

set parser [::xml::parser -characterdatacommand cdata] <--- will pull out
data between tags
set parser2 [::xml::parser -elementendcommand cdata2] <--- will give me
names of tags after END is hit...

is there a way to combine the functionality of these so that I can see what
data falls under which tags?

Thank you for your help and have a great day

 -Anthony
Thread:
Anthony G
Steve Ball
Anthony G
Steve Ball

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved