 	}
 	
 	/// The library XMLElement in the FCPXML document.
-	public var fcpxLibrary: XMLElement {
-		get {
-			let rootElement = self.child(at: 0) as! XMLElement
+	public var fcpxLibrary: XMLElement? {
+		get {
+			guard let rootElement = self.rootElement() else {
+				return nil
+			}
 			return rootElement.elements(forName: "library")[0]
 		}
 	}

	}
	
	

	
	// MARK: - Parsing Functions

	/// An array of all resources in the FCPXML document.
	public var fcpxResources: [XMLElement] {
		get {
			if let resourceNodes = self.fcpxResourceList?.children {
				return resourceNodes as! [XMLElement]
			} else {
				return []
