function folder = getThirdPartyToken(hObj, reqToolName)
% GETTHIRDPARTYTOKEN Get tokens from thrid party xml file

% Copyright 2014-2020 The MathWorks, Inc.

folder = '';
targetFolder = codertarget.target.getTargetFolder(hObj);
attribFileName = codertarget.target.getThirdPartyToolsRegistrationFileName(targetFolder);
if exist(attribFileName, 'file')
    h = codertarget.thirdpartytools.ThirdPartyToolInfo(attribFileName);
    attributes = h.getThirdPartyTools();
    for i=1:numel(attributes)
        toolName = attributes{i}{1};
        if isequal(toolName.ToolName, reqToolName)
            if ispc
                folder = coder.make.internal.transformPaths(attributes{i}{:}.RootFolder, 'pathType', 'alternate');
                folder = strrep(folder, '\', '/');
            else
                folder = attributes{i}{:}.RootFolder;
            end
        end
    end
end