         ///     Relative path to the package.opf file.
         let rootFilePath = container.metadata.rootFilePath
 
-        // Get `Data` from the Container/OPFFile
-        guard let opfData = try? container.data(relativePath: rootFilePath) else {
-            throw EpubParserError.missingFile(path: rootFilePath)
-        }
-        // Create an XML document from the OPF Data
-        do {
-            document = try AEXMLDocument(xml: opfData)
-        } catch {
-            throw EpubParserError.xmlParse(underlyingError: error)
-        }
-
-        // Try to get EPUB version from the <package> element. Else set to
-        // default value.
-        if let version = document.root.attributes["version"],
-            let versionNumber = Double(version) {
-            container.metadata.epubVersion = versionNumber
-        } else {
-            container.metadata.epubVersion = EpubConstant.defaultEpubVersion
-        }
-        
+        // Get the package.opf XML document from the container.
+        document = try getXmlDocumentForFile(in: container,
+                                             atPath: rootFilePath)
+        // Try to get EPUB version from the <package> element.
+        // Else set it to default value.
+        container.metadata.epubVersion = getEpubVersion(from: document)
+
+        // TODO: Add self to links
+        // But we don't know the self URL here
+        //publication.links.append(Link(href: "TODO", typeLink: "application/webpub+json", rel: "self"))
+
+        // Parse Metadata from the XML document.
+        metadata = parseMetadata(from: document,
+                                 with: container.metadata.epubVersion)
+        // Get the page progression direction.
+        if let dir = document.root["spine"].attributes["page-progression-direction"] {
+            metadata.direction = dir
+        }
+        // Look for the manifest item id of the cover.
+        parseSpineAndResources(from: document, to: publication)
+        //
+        publication.metadata = metadata
         publication.internalData["type"] = "epub"
         publication.internalData["rootfile"] = rootFilePath
-        // Add self to links
-        // MARK: we don't know the self URL here
-        //publication!.links.append(Link(href: "TODO", typeLink: "application/webpub+json", rel: "self"))
-        metadata = parseMetadata(from: document,
-                                 with: container.metadata.epubVersion)
-        // Get the page progression direction
-        if let dir = document.root["spine"].attributes["page-progression-direction"] {
-            metadata.direction = dir
-        }
-        publication.metadata = metadata
-
-        // Look for the manifest item id of the cover
-        var coverId: String?
-        let metadataElement = document.root["metadata"]
-
-        if let coverMetas = metadataElement["meta"].all(withAttributes: ["name" : "cover"]) {
-            coverId = coverMetas.first?.string
-        }
-        parseSpineAndResources(from: document, to: publication, with: coverId)
         return publication
     }
 


/// EpubParser support class, parsing the OPF package document in the container.
/// OPF (Open Packaging Format)
open class OPFParser {

    // Mark: - Public methods.

    public init() {}

    // MARK: - Internal methods.

    /// Parse the OPF file of the Epub container and return a `Publication`.
    ///

    /// - Throws: `EpubParserError.missingFile`,
    ///           `EpubParserError.xmlParse`.
    internal func parseOPF(from container: inout Container) throws -> Publication {
        /// The 'to be built' Publication.
        let publication = Publication()
        /// The XML document object representation of the package.OPF file.
        let document: AEXMLDocument
