China's Internet community is abuzz with anger and xenophobia. Netizens are livid over the discovery of an alleged case of attempted rape of a young Chinese woman by a Western tourist in Beijing. The event has also sparked criticism of the ability of the country's police to maintain the rule of law.

A video was posted by one of the original witnesses on popular Chinese video sharing site Youku on May 9, a day after the incident, getting millions of views and the attention of China's official media.

The clip shows a foreign man standing over and attempting to assault a sobbing and distraught Chinese woman, late at night on the streets of China's capital. A group of Chinese men passing by step in to stop the man and proceed to fight him, although it is not clear how many participated or who first initiated the violence. The beaten man was then left in the street amid oncoming traffic until the arrival of police. The entire series of events, from its inception to its street-justice style conclusion, occurred in public on the sidewalk of a major street, only a few minutes' drive from Tiananmen Square.

Beat him well, there's no need to be courteous, said one Youku post. 

Better to just kill him, said another.

Beijing police later announced through their own micro-blogging account that the assailant was a British national who was traveling in China on a tourist visa and may have been under the influence of alcohol.

After the video went viral, the police announced on Monday that they would clean out illegal foreigners from the city. Official media did not officially link the two events, but there was no prior indication that the police were considering actions to rein in illegally resident foreigners.

Beijing police will now carry out a hundred-day campaign to identify illegal foreign residents, entrants and workers. It is unknown what actions exactly would be taken and whether the offenders would be tried under Chinese law or sent back to their countries of origin.

Chinese state media said the numbers of foreigners in China has grown dramatically in past year. In Beijing alone, there is now a stable daily population of nearly 200,000 foreigners, largely visitors or workers in China.

As more people of all backgrounds from around the world come to China to seek adventure, work and fortune, it is becoming increasingly difficult to avoid frictions between them and the Chinese. A large immigrant population of non-ethnic Chinese is relatively unheard-of in the country. 

But not all incidents have generated animosity. Some stories have led to greater respect and admiration for foreign nationals.

Over the past year, stories of visiting foreigners who have come to the assistance of Chinese have been labeled 'Yang Lei Feng' or 'Foreign Lei Feng' stories, after the name of a young soldier in 1960s China famous for his selfless good deeds (though now widely considered by Western analysts to be a creation of Maoist government propaganda).

On May 5, a Brazilian man, later identified in Chinese media only as 'Mozen', was visiting a shopping district in the city of Dongguan in Guangdong province when he came upon a Chinese pickpocket stealing from a woman's purse in the street. People's Daily, a major newspaper published by the Communist Party, reported that while Chinese bystanders simply looked on, the Brazilian man took direct action to stop the thief, even at the cost of his own safety. Thugs later pursued the tourist into a nearby hotel before beating him senseless. Onlookers were unwilling to come forward and assist him, although two witnesses later helped the man to a hospital.

China's Internet forums and social media networks praised the foreigner and reproached Chinese bystanders for being unable to act against lawlessness and come to the assistance of a Good Samaritan. Some netizens on China' popular Web portal NetEase added tongue-in-cheek comments meant to mock Chinese society and the government, saying that foreigners do not understand domestic conditions in China, and to resist foreign involvement in China's internal affairs.