Skip to main content



      Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How to - Open XML file for reading from within plugin install location.
How to - Open XML file for reading from within plugin install location. [message #767113] Fri, 16 December 2011 22:43 Go to next message
Eclipse UserFriend
How to read (parse) and XML file from within the plug-in install location?

I'd like to use XMLMemento to parse an XML file that will be shipped with the plug-in in it's install location.

Thanks in advance.
Re: How to - Open XML file for reading from within plugin install location. [message #768219 is a reply to message #767113] Mon, 19 December 2011 14:25 Go to previous message
Eclipse UserFriend
I found a way to do it. Just in case anyone else is curious on how to do it I'll post the snippet below:

// This gives us /updateSites.xml
URL url = Activator.getDefault().getBundle().getEntry("updateSites.xml");

// This gives us /home/username/.../updateSites.xml
URL absoluteURL = absoluteURL = FileLocator.resolve(url);

// Now create the file
File file = new File(absoluteURL.getFile());

// The file reader
FileReader reader = new FileReader(file);

// Now create the memento
IMemento memento = memento = XMLMemento.createReadRoot(reader);


There you have it! I haven't tried to use a FileWriter; however, I'm pretty sure this is a read only directory.
Previous Topic:Dependency Injection for PDE
Next Topic:Catching selection change event of Stack Frames
Goto Forum:
  


Current Time: Fri Jul 04 12:36:27 EDT 2025

Powered by FUDForum. Page generated in 0.05720 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top