cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Advisor
Advisor
10,572 Views
Registered: ‎02-12-2013

XML parser for TCL

Jump to solution

Guys,

 

I need to parse an xml file from within a tcl script. Reading around on the web it seems like tDOM is the dominant package for parsing xml in tcl but "package require tdom" returns "can't find package tdom".

 

Typing "package names" at the Vivado TCL prompt returns a long list of packages but none seem to be related to XML.

 

Does anyone know how to use an xml parser in Vivado TCL?

 

 

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Mentor
Mentor
18,885 Views
Registered: ‎02-24-2014

Re: XML parser for TCL

Jump to solution

Ok,  I think I have a solution for this..    This solution was run on Kubuntu 14.04, and probably needs a lot of modification for Windows 7, or other operating systems.

 

first download tDOM from github

 

git clone https://github.com/tDOM/tdom.git

sudo apt-get install pkg-config tcl-dev

cd tdom/unix

../configure

make

sudo make install

 

Now at this point, you should see " Install pkgIndex.tcl /usr/lib/tdom0.8.3" in the output during installation (this version number will probably change in the future).

 

Open your Vivado GUI, and type this in the TCL console:

puts [lappend auto_path "/usr/lib/tdom0.8.3"]

 

Now you can type "package require tdom", and see this:

package require tdom
0.8.3

 

To avoid having to modify $auto_path everytime, set this in your .bashrc

export TCLLIBPATH=/usr/lib/tdom0.8.3

 

Although this has the property of putting tdom at the FRONT of the directory search paths, rather than the end, so be aware of this difference.

 

I used to be a Xilinx FAE,  so I'm happy to know I can still fix problems like this.....

 

 

Don't forget to close a thread when possible by accepting a post as a solution.

View solution in original post

6 Replies
Highlighted
Scholar
Scholar
10,554 Views
Registered: ‎06-05-2013

Re: XML parser for TCL

Jump to solution

@pedro_uno What you want do?

 

you can parse the file and make some changes using simple open and read in vivado tcl console as well.

 

set fd [open "/tmp/testdata.xml "w"]
file4
% set a [read $fd]

 

-Pratham

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Advisor
Advisor
10,543 Views
Registered: ‎02-12-2013

Re: XML parser for TCL

Jump to solution

I want to be able to navigate the XML tree in my TCL script.

 

XML parsers read the xml input and create a proper TCL list.  TCL lists are designed to contain this sort of hierarchal information because TCL lists can contain lists. These techniques are very mature and common.

 

The tDOM library seems to be the richest but there are other lightweight packages.  Look here for a discussion of XML with TCL.  http://wiki.tcl.tk/1948

 

It looks like the two technologies evolved together.  In fact, EDA information often exists as XML files. What does Xilinx itself use to parse XML in TCL?  I'm sure that would be sufficient for anything I need to do.

 

    Pete

----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos
Highlighted
Newbie
Newbie
10,498 Views
Registered: ‎11-12-2015

Re: XML parser for TCL

Jump to solution

Did you ever find the answer to this?  I am in the same boat as you.

 

Ron

0 Kudos
Highlighted
Anonymous
Not applicable
10,491 Views

Re: XML parser for TCL

Jump to solution

Ron,

 

No, I have not made any progress on this. I did not want to push too hard if I was the only person interested.

 

Maybe it is time to ask my FAE. He has quickly found the answer to several things that stumped the forums.

 

I'm thinking that Xilinx must have some kind of XML parser built into their standard xTCL interface because so many of their files are in XML format.

 

  Pete

0 Kudos
Highlighted
Mentor
Mentor
18,886 Views
Registered: ‎02-24-2014

Re: XML parser for TCL

Jump to solution

Ok,  I think I have a solution for this..    This solution was run on Kubuntu 14.04, and probably needs a lot of modification for Windows 7, or other operating systems.

 

first download tDOM from github

 

git clone https://github.com/tDOM/tdom.git

sudo apt-get install pkg-config tcl-dev

cd tdom/unix

../configure

make

sudo make install

 

Now at this point, you should see " Install pkgIndex.tcl /usr/lib/tdom0.8.3" in the output during installation (this version number will probably change in the future).

 

Open your Vivado GUI, and type this in the TCL console:

puts [lappend auto_path "/usr/lib/tdom0.8.3"]

 

Now you can type "package require tdom", and see this:

package require tdom
0.8.3

 

To avoid having to modify $auto_path everytime, set this in your .bashrc

export TCLLIBPATH=/usr/lib/tdom0.8.3

 

Although this has the property of putting tdom at the FRONT of the directory search paths, rather than the end, so be aware of this difference.

 

I used to be a Xilinx FAE,  so I'm happy to know I can still fix problems like this.....

 

 

Don't forget to close a thread when possible by accepting a post as a solution.

View solution in original post

Highlighted
Advisor
Advisor
10,444 Views
Registered: ‎02-12-2013

Re: XML parser for TCL

Jump to solution
Thanks man, that is a really good solution for me since I nearly always use Vivado under Ubuntu.
----------------------------------------
DSP in hardware and software
-----------------------------------------
0 Kudos