From: Anthony G <ant...@gm...> - 2007-01-31 23:33:09
|
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 |