Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6074105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:20:42+00:00 2026-05-23T10:20:42+00:00

So, we are using a webBrowser control in edit mode, to allow people to

  • 0

So, we are using a webBrowser control in edit mode, to allow people to enter text, and then take that text and send it out to the server for everyone to see. IE, it’s an HTML input box.

The HTML output from that box isn’t standard XHTML, given that it’s just a webBrowser control, so i needed a method to convert any bad HTML to XHTML. I read up on SGML, and subsequently have used:

private static string Html2Xml(string txtHtmlString)
    {
        var xhtml = new Sgml.SgmlReader();
        var sw = new StringWriter();
        var w = new XmlTextWriter(sw);
        xhtml.DocType = "HTML";
        xhtml.InputStream = new StringReader(txtHtmlString);

        while ((!xhtml.EOF))
        {
            w.WriteNode(xhtml, true);
        }

        w.Close();
        return sw.ToString();
    }

I basically pase HTML string to that method, and it returns ‘suposed’ proper XHTML. However, it’s not passing XHTML checks, and the data it returns is just a basic

<html><head></head><body></body></html> 

Format. Thus, not proper XHTML.

So, how can i format that to actually output proper XHTML? There isn’t much on MindShares site for SGML documentation anymore, so not sure where to go from here.

Essentially, we need the HTML from the WebBrowser control, which isn’t valid XHTML, to output to XHTML, so that we can attach it to an XMPP.msg.Html element (valid XHTML only). If the system detects that any codes within the HTML is invalid, it marks the XMPP.msg.Html as blank, so i know the above method isn’t working.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:20:42+00:00Added an answer on May 23, 2026 at 10:20 am

    Would reccomend using either something like TinyMCE or HtmlAgilityPack (available as a Nuget package or from codeplex).

    TinyMCE allows users to perform a rich text edit with appropriate formatting controls, and will output the resultant Html.

    HtmlAgilityPAck on the other hand is a library that will allow you to pass in the HtmlStream generated by your method, and output this as a valid Xhtml stream.

    Rough example for working with this in the HtmlAgilityPAck as below:

    var sb = new StringBuilder(); 
    var stringWriter = new StringWriter(sb);
    
    string input = "<html><body><p>This is some test test<ul><li>item 1<li>item2<</ul></body>";
    
    var test = new HtmlAgilityPack.HtmlDocument();
    test.LoadHtml(input);
    test.OptionOutputAsXml = true;
    test.OptionCheckSyntax = true;
    test.OptionFixNestedTags = true;
    
    test.Save(stringWriter);
    
    Console.WriteLine(sb.ToString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using the .NET WebBrowser control in edit mode as part of
Without using a WebBrowser control, how could I execute a JavaScript function, that is
I am using the webbrowser control in winforms and discovered now that background images
I am using WebBrowser control to send post data. There is overloaded Navigate method
I'm using the webBrowser control to surf to a page that has an Iframe.
I'm using WebBrowser control to take screen shots of web pages and I'm able
I'm using Webbrowser control to login to HTTPS site with untrusted certificate. but I
I'm using th WebBrowser control in the .net 2.0 framework. Is it possible to
I am using the webbrowser control in visual studio. I think it is a
I'm using a WebBrowser control in my Visual C# (.net 2.0) application. Now I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.