Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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] Sat, 17 December 2011 03:43 Go to next message
John Steele is currently offline John SteeleFriend
Messages: 33
Registered: June 2010
Location: Seattle, WA
Member
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 19:25 Go to previous message
John Steele is currently offline John SteeleFriend
Messages: 33
Registered: June 2010
Location: Seattle, WA
Member
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: Thu Apr 18 10:43:18 GMT 2024

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

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

Back to the top