Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Validate xml against DTD

Validate xml against DTD

Scheduled Pinned Locked Moved C#
csharpcomsysadminxmlhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rohit16db
    wrote on last edited by
    #1

    Hi guys, Hope you are doing well. I have a Onix complaint XML document that I want to validate it with some Onix complaint DTD. I did coding for same in C# XmlReaderSettings settings = null; try { string xmlPath = Server.MapPath("XML/nielsen_onix.XML"); //Load XML into XmlTextReader // reader = new XmlTextReader(xmlPath); //Load XmlTextReader into XmlValidatingReader settings = new XmlReaderSettings(); //Set the validation type settings.ValidationType = ValidationType.DTD; settings.ProhibitDtd = false; settings.CheckCharacters = false; //Hook up the XmlValidatingReader’s //ValidationEventHandler to a call //back method named ValidationCallBack settings.ValidationEventHandler += new ValidationEventHandler( this.ValidationCallBack); XmlReader reader = XmlReader.Create(xmlPath, settings); //Read through the XML document by calling //the Read() method while (reader.Read()) { } //Check boolean field named valid (located at top of code) if (valid) Response.Write("Validation is Successful!"); reader.Close(); } catch(Exception ex) { Response.Write(ex.Message); } This code runs good and show the xml file invaid while my xml file is valid when I validated it on http://www.w3schools.com/XML/xml_validator.asp[^] Could you please check what's wrong going with me? Any help would be highly appreciable. Thanks Rohit

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups