NEW YORK (Reuters) - Former U.S. Secretary of State Condoleezza Rice said on Monday she would prefer that President Donald Trump not criticize judges and the media but that U.S. democratic institutions can withstand such comments.

Speaking in an interview, Rice also described Trump as having a somewhat “transactional” view of foreign relations but she broadly endorsed his approach of seeking to enlist China’s help to get North Korea to rein in its nuclear program.

Asked about Trump lashing out at judges when rulings go against him and describing the media as “the enemy of the people,” Rice replied: “It’s language that I would prefer not to hear.

“But I don’t think that you can erode the scaffolding of democracy in the United States,” she added during a tour to promote her book “Democracy: Stories from the Long Road to Freedom.”

Rice, national security adviser and secretary of state under Republican former President George W. Bush, is now a professor at Stanford University.

She described U.S. institutions as “very strong” and said Trump “may have even found himself a bit surprised by how constraining that scaffolding really is.”

Courts have blocked parts of two Trump executive orders that sought to temporarily ban entry to the United States for people from six Muslim-majority countries.

Slideshow ( 3 images )

In a 30-minute interview, Rice said the United States needed to find a way to punish Russia for its alleged interference in the 2016 U.S. election but without engaging in ‘tit-for-tat’ retaliation by meddling in Russian elections.

She suggested prosecuting anyone in the United States who took part in what intelligence agencies believe was a deliberate effort to sway the presidential election in Trump’s favor, and to consider putting sanctions, such as visa bans, on people who did so from abroad.

‘TRANSACTIONAL VIEW’

Rice, who has interspersed periods in public service with academic posts, suggested Trump, a New York real estate magnate, may see foreign policy more in terms of striking deals than finding common interests.

Before meeting Chinese President Xi Jinping last month, Trump suggested China might get better trade deals with the United States if it put more pressure on North Korea to restrain its nuclear and missile programs.

“The president still has a kind of transactional view of international politics but, in fact, interests are more enduring than transactions,” Rice said.

Slideshow ( 3 images )

However, Rice endorsed Trump’s policy of trying to enlist Chinese help against North Korea, which is believed to have conducted five nuclear tests since 2006 and to be developing intercontinental ballistic missiles that could strike the U.S. mainland.

China, the North’s main trading partner and the closest thing it has to an ally, has historically been unwilling to tighten the economic screws on Pyongyang for fear of triggering a collapse and sending millions of refugees across the border.

Rice said the U.S. task was to convince the Chinese that they had to choose between doing “really hard things to bring this regime into line or we will have to do harsh things.”

The former secretary of state also said North Korea’s current leader, Kim Jong Un, is far less predictable than his father, Kim Jong Il, and may not be fully rational.

“Kim Jong Un is far more reckless than his father ... I wonder if he is not a little unhinged,” she said. “I wonder if the Chinese aren’t beginning to reconsider their view that ... a stable North Korean regime, even if it is nuclear-armed, is better than an unstable one.”