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. How to open a XML file without validating?

How to open a XML file without validating?

Scheduled Pinned Locked Moved C#
xmlhelptutorialquestion
3 Posts 2 Posters 2 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.
  • H Offline
    H Offline
    Hariharan2105
    wrote on last edited by
    #1

    Hi, I need to open a well-formatted xml file (but not valid against DTD), i tried the following, sill reciving error: // <!DOCTYPE article SYSTEM "xyz.dtd"> txtReader = new XmlTextReader(@"D:\abc.xml"); reader = new XmlValidatingReader(txtReader); reader.ValidationType = ValidationType.None; xDoc = new XmlDocument(); xDoc.Load(reader); Regards, Hariharan C.

    P 1 Reply Last reply
    0
    • H Hariharan2105

      Hi, I need to open a well-formatted xml file (but not valid against DTD), i tried the following, sill reciving error: // <!DOCTYPE article SYSTEM "xyz.dtd"> txtReader = new XmlTextReader(@"D:\abc.xml"); reader = new XmlValidatingReader(txtReader); reader.ValidationType = ValidationType.None; xDoc = new XmlDocument(); xDoc.Load(reader); Regards, Hariharan C.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      If you don't want to validate the XML file against a DTD, why are you using the XmlValidatingReader at all? Just remove it. BTW, unless you are still using .NET 1.x, the XmlValidatingReader[^] is now obsolete. You should use the validation options available on the XmlReader class instead.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      H 1 Reply Last reply
      0
      • P pmarfleet

        If you don't want to validate the XML file against a DTD, why are you using the XmlValidatingReader at all? Just remove it. BTW, unless you are still using .NET 1.x, the XmlValidatingReader[^] is now obsolete. You should use the validation options available on the XmlReader class instead.

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        H Offline
        H Offline
        Hariharan2105
        wrote on last edited by
        #3

        Hi, I am new to C#. I tried with the following and succeeded, txtReader = new XmlTextReader(@"abc.xml"); txtReader.XmlResolver = null; xDoc = new XmlDocument(); xDoc.Load(txtReader) Thanks, Hariharan C.

        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