New Fashion Windows 8 Development (31): Remove HTML tags from text

Source: Internet
Author: User

Tell everybody a good news. Remove the HTML mark in the string and no longer need to write regular expressions. Do you know? One rowCodeThat's enough!

It's not too late. Come on.

 

1. Create a new "Panel tile" ApplicationProgramProject.

2. Put a textbox on the interface to input HTML text, a button, click to convert, and a textblock to display the converted string. The XAML is as follows:

<Page X: class = "app1.mainpage" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" xmlns: Local = "using: app1" xmlns: D = "http://schemas.microsoft.com/expression/blend/2008" xmlns: MC = "http://schemas.openxmlformats.org/markup-compatibility/2006" MC: ignorable = "D"> <grid background = "{staticresource applicationpagebackgroundthemebrush}"> <grid. rowdefinitions> <rowdefinition/> <rowdefinition Height = "Auto"/> <rowdefinition/> </grid. rowdefinitions> <textbox X: Name = "txtinput" grid. row = "0" textwrapping = "Wrap"/> <button grid. row = "1" margin = "," content = "convert" Click = "onclick"/> <scrollviewer grid. row = "2" verticalscrollbarvisibility = "visible" horizontalscrollmode = "enabled"> <textblock X: name = "tbresult" fontsize = "24" textwrapping = "Wrap"/> </scrollviewer> </GRID> </Page>

3. Then we process the click event in the code. Remember to introduce the windows. Data. html namespace first.

 
Private void onclick (Object sender, routedeventargs e) {This. tbresult. Text = htmlutilities.converttotext(this.txt input. Text );}

 

Then, try it.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.