php if else语句不回显else

I'm trying to echo Norwegian language if there is a xmllang="no" if not echo "noname". Like

000000000121698001,

text 000000000121699001,noname

But this is only returning all productids that have a xmllang="no" and not printing productId with no xmllang="no"

XML

<catalog>
<product productid="000000000121698001">
    <displayname xmllang="da">text</displayname>
    <displayname xmllang="fi">text</displayname>
    <displayname xmllang="no">text</displayname>
    <displayname xmllang="sv">text</displayname>    
</product>

<product productid="000000000121699001">
    <displayname xmllang="da">test</displayname>
    <displayname xmllang="x-default">test</displayname>
    <displayname xmllang="sv">test</displayname>
</product>

PHP

foreach ($xml->product as $product) {

    foreach ($product->displayname as $name) {
        switch((string) $name['xmllang']) {
            case 'no':

                echo $product->attributes()->productid. ",";

                if (isset($name)){
                    echo $name. ",", PHP_EOL;
                } else {
                    echo 'noname ,';
                }
                echo "<br>
";
        }
    }
}

I would split this into two parts: 1st prepare the data and find the correct localized labels or set a default; then 2nd output the data in whatever format (or pass the $idList to a template ideally).

<?php
/** @var SimpleXMLElement $xml */

$idList = [];

/* Prepare the data */
foreach ($xml->product as $product) {
    $fallbackLabel = null;

    /* Iterate over the display names */
    foreach ($product->displayname as $name) {
        /* And search for the one in a matching language */
        switch ((string)$name['xmllang']) {
            case 'no':
                $idList[$product->attributes()->productid] = $name;
                break;
            case 'x-default':
                $fallbackLabel = $name;
                break;
        }
    }

    /* If no name in the searched language was found, set a fallback here */
    if (!isset($idList[$product->attributes()->productid])) {
        if (!empty($fallbackLabel)) {
            /* If a label with a language code of "x-default" was found, use that as fallback label */
            $idList[$product->attributes()->productid] = $fallbackLabel;
        } else {
            /* …if not set a static text */
            $idList[$product->attributes()->productid] = 'noname';
        }
    }
}

/* Output the data */
foreach ($idList as $id => $label) {
    echo sprintf("%s,%s<br>
", $id, $label);
}