How to read/parse XML files inside SU
-
Hello,
What is the best way to read/parse XML files inside a SU Ruby script?
Do I need a specific XML Ruby library or do SU support this natively?Regards,
Fernando. -
It depends on what the XML structure and data represent. For processing XML there are some Ruby libraries, i. e. REXML (but REXML seems to be a bit slow). I have used it for ModelHistory which isn't in the wild because I'm lazy
azuby
-
one idea, if you are on Windows (dont know about Mac) - use win32api and load xerces-c_2_6.dll that is available with Sketchup distro
-
@azuby said:
It depends on what the XML structure and data represent. For processing XML there are some Ruby libraries, i. e. REXML (but REXML seems to be a bit slow). I have used it for ModelHistory which isn't in the wild because I'm lazy
azuby
So...is it true that REXML is not part of the Ruby SketchUp distribution? How do I use this library? I downloaded REXML from this site:
http://www.germane-software.com/software/rexml/It comes as a zip file that contains a ton of files. Do I need to include all these files with my plugin if I want to use the REXML API? I would like to include just one file if possible.
Thanks.
-
If I remember right, I had a fully installed Ruby on my PC and took the REXML lib from it. The directory contains 55 files and five folders. I loaded it this way from my script:
require 'rexml/document' unless defined? REXML
If you also want to load this way you have to make sure that the Ruby interpreter search in the right place. Put the REXML folder to Plugins or Tools folder - should work with the above code.
To make sure that your script only runs if REXML is loaded, put this condition to your codee:
if defined? REXML # YOUR CODE HERE else UI.messagebox "REXML is missed, can't load plugin." end
Sorry for my late answer - I'm moving from town to town at the moment.
azuby
Advertisement