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. Xml - DTD processing

Xml - DTD processing

Scheduled Pinned Locked Moved C#
helpcsharpcomsysadmindata-structures
3 Posts 3 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.
  • P Offline
    P Offline
    Patrick Klug
    wrote on last edited by
    #1

    Hello! I am trying to read an XML file that specifies an external DTD source, namely http://www.apple.com/DTDs/PropertyList-1.0.dtd When I execute the reader.MoveToContent() in the code below

    System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
    settings.ProhibitDtd = false;
    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(uri, settings))
    {
    reader.MoveToContent();

    customers sometimes get this exception:

    Exception : System.Xml.XmlException
    Message : An error has occurred while opening external DTD 'http://
    www.apple.com/DTDs/PropertyList-1.0.dtd': Unable to connect to the remote server
    Source : System.Xml
    Help :
    OSVersion : Microsoft Windows NT 5.1.2600 Service Pack 2
    Thread :
    Stack :
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)

    ...

    Exception : System.Net.Sockets.SocketException
    Message : A socket operation was attempted to an unreachable host

    Weird is that the customers have internet access because the XmlReader is created from an uri... but the DTD seem to be not available. Can I somehow deactivate the DTD processing completely? :confused: :mad: Any hints would be greatly appreciated. TIA Pakl

    S R 2 Replies Last reply
    0
    • P Patrick Klug

      Hello! I am trying to read an XML file that specifies an external DTD source, namely http://www.apple.com/DTDs/PropertyList-1.0.dtd When I execute the reader.MoveToContent() in the code below

      System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
      settings.ProhibitDtd = false;
      using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(uri, settings))
      {
      reader.MoveToContent();

      customers sometimes get this exception:

      Exception : System.Xml.XmlException
      Message : An error has occurred while opening external DTD 'http://
      www.apple.com/DTDs/PropertyList-1.0.dtd': Unable to connect to the remote server
      Source : System.Xml
      Help :
      OSVersion : Microsoft Windows NT 5.1.2600 Service Pack 2
      Thread :
      Stack :
      at System.Xml.XmlTextReaderImpl.Throw(Exception e)

      ...

      Exception : System.Net.Sockets.SocketException
      Message : A socket operation was attempted to an unreachable host

      Weird is that the customers have internet access because the XmlReader is created from an uri... but the DTD seem to be not available. Can I somehow deactivate the DTD processing completely? :confused: :mad: Any hints would be greatly appreciated. TIA Pakl

      R Offline
      R Offline
      Russell Jones
      wrote on last edited by
      #2

      is it possible to get a local copy of the dtd and validate against that? It may be that some transient error is causing you a problem. Russ

      1 Reply Last reply
      0
      • P Patrick Klug

        Hello! I am trying to read an XML file that specifies an external DTD source, namely http://www.apple.com/DTDs/PropertyList-1.0.dtd When I execute the reader.MoveToContent() in the code below

        System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
        settings.ProhibitDtd = false;
        using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(uri, settings))
        {
        reader.MoveToContent();

        customers sometimes get this exception:

        Exception : System.Xml.XmlException
        Message : An error has occurred while opening external DTD 'http://
        www.apple.com/DTDs/PropertyList-1.0.dtd': Unable to connect to the remote server
        Source : System.Xml
        Help :
        OSVersion : Microsoft Windows NT 5.1.2600 Service Pack 2
        Thread :
        Stack :
        at System.Xml.XmlTextReaderImpl.Throw(Exception e)

        ...

        Exception : System.Net.Sockets.SocketException
        Message : A socket operation was attempted to an unreachable host

        Weird is that the customers have internet access because the XmlReader is created from an uri... but the DTD seem to be not available. Can I somehow deactivate the DTD processing completely? :confused: :mad: Any hints would be greatly appreciated. TIA Pakl

        S Offline
        S Offline
        Super Lloyd
        wrote on last edited by
        #3

        From MS newsgroup: == XmlReader always checks if DTD exists (to make sure document is wellformed), it doesn't actually parse it. So the solution is to provide to XmlReader custom XmlResolver, which will return something dummy when requested to resolve "http://www.apple.com/DTDs/PropertyList-1.0.dtd". ==

        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