OpenXmlPart.getPartsByRelationshipType (relationshipType)

Return to the
Open XML SDK for JavaScript
Developer Center
Gets an array of parts with the specified relationship type. openXml.relationshipTypes contains a list of the most common relationship types.


    var parts = OpenXmlPart.getPartsByRelationshipType(relationshipType);


    relationshipType: An string that contains the relationship type.

Return Value

    Returns an array of OpenXmlPart objects. If there are no parts with the specified relationship type, this function returns a zero length array.


    var parts = doc.mainDocumentPart()


// Open a document that contains headers and is stored as a base64 string.
var doc = new openXml.OpenXmlPackage(documentWithHeaders_base64);
// Get the main document part.
var parts = doc.mainDocumentPart().getPartsByRelationshipType(openXml.relationshipTypes.header);
o = ["Number of parts: " + parts.length];
for (var i = 0; i < parts.length; i++) {
    o.push("Part #" + (i + 1).toString() + " uri: " + parts[i].uri);
// Note that there are convenience functions that retrieve the most commonly used parts.
var parts2 = doc.mainDocumentPart().headerParts();
o.push("doc.mainDocumentPart().headerParts() found the same " + parts2.length + " parts.");
return { output: o };