Image copyright Getty Images Image caption The prince visited an elephant sanctuary on the final day of his tour in China

Prince William kept the best for last. After two days of diplomatic pleasantries and ribbon cutting, his third and final day of engagements in China included delivering a basket of carrots to a 13-year-old Asian elephant called Ran Ran.

The prince does a lot of charity work to highlight elephant poaching and the trade in ivory.

At the elephant sanctuary in southwest Yunnan province, he heard about the dangers to China's remaining 250 wild elephants.

Ran Ran herself was found in 2005 with her leg in an iron trap.

But as Prince William heard from local conservationists and forestry police, the greatest threat to China's wild elephants is no longer poaching but habitat destruction.

It's the same story I heard when I spent three days with Chang Zongbo of the forestry police, a man who has spent his life trying to protect what remains of Yunnan's rainforest and its wildlife.

Image caption Chang Zongbo, seen here next to a rubber plantation, has dedicated his life to protecting China's elephants

"It's war." Chang Zongbo turns round in the driver's seat to make his point. He does that a lot. And when he does, he's not looking at the road ahead. Which is disconcerting.

A couple of times we drift into the path of oncoming traffic and as Officer Chang is passionate about most of his points, he's looking backwards more often than forwards. Our police jeep slows to elephant walking pace.

"Stop talking to the driver if you want to arrive alive," says my cameraman. He has a point.

I take a vow of silence and turn my attention to the view. Rubber trees as far as the eye can see, like infantry marching the hillsides in stiff lines each with a camouflage helmet of red leaves.

Where is the legendary Yunnan rainforest that I've heard so much about? Home to the elephants as well as nearly three quarters of China's protected animal species and all the exotic species of trees and flowers that have brought plant hunters across the globe for centuries?

Before I know it, another question has popped out of my mouth and Chang Zongbo is turning around again to explain that rubber is lucrative for the farmer but a daunting enemy for anyone interested in biodiversity or wildlife.

"Rubber plantations are a dead zone. The trees sucks up all the water. "Nothing can grow near rubber. It kills biodiversity and erodes the soil," he says, pointing up to the cap of rich green forest crowning the highest peaks.

"Rubber can't grow on the mountaintops so they leave that for the elephants."

Image caption Mr Chang bathes an adult elephant

In all his 27 years with China's forestry police, Chang Zongbo has climbed every one of these mountains, tracking poachers and loggers.

"A bag of rice, a lighter, salt and a knife. That's all I need to set off with," he says. "We eat fruit and berries. Or we catch fish. We go for days, following the poachers and then waiting till they're asleep at night. That's the safest time to arrest them."

Mr Chang said he's been involved in 400 arrests. And even has scars to show from the ones that got rough.

Killing an elephant carries the death penalty in China, a powerful reason for the poacher to resist arrest. Chang Zongbo can name you the five men executed during his career. This is clearly personal.

Elephants are so clever; build an electric fence and they get a branch to break it Chang Zongbo, Forestry police officer

And that part, at least, has worked. The combination of intensive public education and fear of the death penalty mean that while the Chinese market may be hungry for ivory, it's the African elephant and not the Asian elephant which is dying to provide it.

Ironically, China is probably one of the safest place to be for an elephant these days, at least in terms of poacher risk.

The problem in China is the disappearing forest. The remaining elephants' habitat is under relentless pressure.

Uninvited guests

"The forest is God. That's what my dad used to say." Chang Zongbo's dad belonged to the Dai ethnic minority who revere the rainforest as sacred.

The son has inherited his father's passion but after six hours of driving through rubber plantations, I'm only too grimly aware of the scale of his battle.

Image caption Marauding elephants have become a common sight in neighbouring villages

Image caption Part of Mr Chang's work involves communicating with villagers to educate them about the elephants

Today's small frontline is to be built of concrete - a wall to protect the people from the elephants and vice versa.

The fact is that the elephants are marauding. There's no polite word for it. But it's hardly their fault.

Once their reserves were surrounded by natural forest in which they could roam. Now the reserves are islands, completely cut off from each other by rubber plantations.

And so the elephants break out and go down to the villages to see what they can steal. They gorge on bananas and sugar cane. Occasionally they trample farmers to death.

In one village, Mr Chang shows me the remains of the pumpkin harvest. A herd of elephants has been through, leaving a pulpy mess and some giant footprints at the scene of their feast.

"Elephants are so clever. Build an electric fence and they get a branch and break it. Plastic sheeting, they'll smash right through it. Trenches, they fill them with mud. And when they come back, they bring their friends," he says.

"These farmers try everything to fend them off…. firecrackers, gongs. It's a difficult situation."

Mr Chang is here to protect the elephants but he's also sympathetic to the plight of the farmers. The government does pay compensation for their crops but not enough to cover the cost of the damage.

"I see this over and over. When the elephants first come, the villagers are excited and curious. But when they don't leave, that's when the trouble starts."

It's like a visit from Tudor royalty. At first, the hosts feel honoured but as weeks go by, with the court carousing at their expense and fouling their castle, the welcome wears thin.

Hence the concrete wall. Mr Chang is supervising the delivery of the cement.

As we arrive, the village loudspeaker is blaring out a warning about the penalties for clearing forest and planting rubber illegally. Rubber is king here as in every other town and village we've passed through.

Image caption While his job is to protect the elephants, Mr Chang insists he remains sympathetic to the farmers

For one thing, unlike bananas and sugar cane, elephants can't eat it. And it pays for progress. Concrete homes are springing up alongside the old-style wooden stilt houses.

There are adverts for air conditioners on village walls and a van is blaring out an irritating mobile phone jingle, competing with the loudspeaker of the forestry police.

We do the six-hour drive back mostly in silence. At one point, Mr Chang waves at a hillside and frowns.

"We had a protection order on that land but then the farmers got an education, read up on the law and went to court to claim it back," he says. "They won and we had to give it up. Look at it now. All rubber."

So is he losing his war?

"Every patch of forest, I work to save it. Every elephant, I work to save it. So when I look my grandchildren in the eye, I can tell them I did my best. I think I can be proud of that."

It's a message Prince William would echo. Just before leaving Yunnan for London, he told a group of young forest rangers: "The future of these animals is down to your generation. You are the ones that are going to have to speak up."