How to iterate org.eclipse.emf.ecore.resource.Resource Object

269 Views Asked by At

I have managed to parse the XML file and create the resource object using EMF Modelling, How do I retrieve the data's from the XML file ? Attached the Ecore Model. Parsing method Ecore

2

There are 2 best solutions below

2
On
resource.getContents()

to retrieve the list of root semantic elements in the resource. Usually there is only 1.

0
On

Depending on your scenario you may also use getAllContents() which returns a TreeIterator. It might be useful if you want to, say, iterate over all instances of a particular type.