07-29-2013, 02:24 PM #1
- 12 Posts
Currently I'm working on an app that has code elements from the WordPress sample built-in. This means however, that posts show up in a WebBrowser control. As the WebBrowser control overrides the gesture events, swipes to the left or right are being ignored by the pivot.
I'm currently passing the source of the WebBrowser to a RichTextBox, but I've been unable to remove HTML-tags, like <p class="">, <img>, etc.
var html = new StringBuilder();
When I remove the html.Append(htmlSubString); the entire content of the textbox disappears...
I'm currently trying to use this code as a "filter", but it does not seem to work. As I've never worked with this part of coding before, it's hard for me to understand why this doens't work.
It would be great if someone could show me a revised version of my code or some website with an explanation so I can finally finish this app.
Also IF it is not too much of a problem, I'd like the images in the HTML to be converted into an image in XAML.
Anyone know how to do this? If not, thanks for reading anyway
07-29-2013, 04:54 PM #2
- 663 Posts
I personally have not used this yet but it seems that many are using the HTMLAgilityPack library to convert HTML content to a DOM structure that you can then use either XPath or LINQ to extract and transform.
Codeplex site: Html Agility Pack - Home
Nuget page: NuGet Gallery | HtmlAgilityPack 1.4.6
Nokia article: HTML Page parsing using HTMLAgilityPack - Nokia Developer Wiki
08-17-2013, 06:14 PM #3
- 2 Posts
Well, if this is actual code sequence, then no surprise that it's not working.
First of all you are calling Replace method on empty String(Builder), so first line should be:
var html = new StringBuilder(htmlSubString); // htmlSubString or whatever your source html is.
Then replace will do nothing. You should consider using regexes to detect starting and ending tags.
Next, StringBuilder is used to create/edit a string, when you are going to do many append's.
So to remove some tags on string, it wont be needed.
So go with this:
string filteredHtml = System.Text.RegularExpressions.Regex.Replace(initialHtml, "A regex pattern that matches starting OR ending tags", "");
BTW, if you're not so much familiar with regex, RegExr is a good place to start testing.
- By Parteek Agnihotri in forum Nokia Lumia 920Replies: 105Last Post: 08-03-2013, 04:48 PM
- By BIGPADDY in forum PlaystationReplies: 11Last Post: 08-01-2013, 08:38 PM
- By ballanda in forum Nokia Lumia 925Replies: 5Last Post: 08-01-2013, 07:33 AM
- By gsquared in forum Nokia Lumia 1020Replies: 3Last Post: 07-29-2013, 02:55 PM
- By BIGPADDY in forum PlaystationReplies: 6Last Post: 07-29-2013, 01:45 PM