validating Xhtml Strict with Csharp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #1

    validating Xhtml Strict with Csharp

    Hi all,

    I am writing a form for end users to input XHTML that will be displayed on the site.

    I know that is way too much trust for my users but what can you say you gotta do what the boss wants. Anyway ...

    How do i validate the input, i "intelisens e browsed" and i worked out how to validate xml, but i can't get it to change the schema it uses.

    This is the standard xml parser.
    Code:
            XmlDocument xmld = new XmlDocument();
            try
            { xmld.LoadXml(TextBox1.Text);}
            catch (Exception exc)
            {Response.Write(exc.Message.ToString()); }
    This is my attempt at loading in the dtd from w3c
    Code:
            XmlSchemaSet sch = new XmlSchemaSet();
            XmlSchema xmlSch = new XmlSchema();
            XmlSchemaSet schcopy = new XmlSchemaSet();
    
            xmlSch.SourceUri = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
            xmlSch.Namespaces.Add("xmlns", "http://www.w3.org/1999/xhtml");
            sch.Add(xmlSch);
    All the later does is stop working when i step through when it reaches the SourceUri line of the code.

    If anyone can help me i would be grateful...

    Harj

    The Coders Advocate
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    System.XML.Sche ma.XmlSeverityT ype

    Comment

    • harshmaul
      Recognized Expert Contributor
      • Jul 2007
      • 490

      #3
      hi,
      Thanks for the response. However you gave me an enum, with no direction. can you give me an object or something that i can browse.

      Comment

      Working...