tags:

views:

36

answers:

1

Greetings,

I'm new to TCL scripting, and I have a very very basic xml file which I need to import information from into tcl.

Example of XML Document Structure:

<object>
  <type>Hardware</type>
  <name>System Name</name>
  <description>Basic Description of System.</description>
  <attributes>
      <vendor>Dell</vendor>
      <contract>MM/DD/YY</contract>
      <supportExpiration>MM/DD/YY</supportExpiration>
      <location>Building 123</location>
      <serial>xxx-xxx-xxxx</serial>
      <mac>some-mac-address</mac>
  </attributes>
</object>

Etc...

I've seen something called TCLXML but I'm not sure if this is the best route or even how to create the package to use it..

Any help will be greatly appreciated.

+2  A: 

I can recommend using the tdom package for XML parsing, particularly as it includes good integration with XPath so extracting things from the data is easy. It's also pretty fast.

If you're using ActiveTcl, then it's already part of it (though you might need to do a teacup update to bring it in from the repository).

Donal Fellows
Thank you, this is helpful. I tried package require tdom and it was not found, so I have downloaded tDom from the website. How can I set the path to look for this newly downloaded package?
pws5068
The directory where you installed it (you did build and install it, yes?) – *or* its parent directory – needs to be on Tcl's `auto_path` list.
Donal Fellows
I downloaded the win32 DLL's
pws5068
It's working, thank you for your assistance.
pws5068