code not work 2003

Last post 03-05-2008 4:19 PM by hong_ma. 7 replies.

Sort Posts:

  • code not work 2003

    03-01-2008, 8:51 PM
    • Participant
      792 point Participant
    • hong_ma
    • Member since 05-10-2005, 2:05 PM
    • Posts 194

    the code below. We need to use these settings to tell the parser not to get the dtd. The web service returns a dtd link in the document we do NOT want to parse this! this code from 2005. it works fine. how can we do same thing in 2003. looks like not settings.ProhibitDtd in 2003. thanks

    WebResponse response = request.GetResponse();

    XmlReaderSettings settings = new XmlReaderSettings();

     settings.ProhibitDtd = false;

    settings.XmlResolver = null;

    xmlReader = XmlReader.Create(response.GetResponseStream(), settings);

  • Re: code not work 2003

    03-02-2008, 11:36 AM
    • All-Star
      46,040 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    XmlReaderSettings represents evolution in working with XML in .NEt 2.0 and newer(morer abstraction over the XmlReaders and -writers). It does not exist in v1.x (which VS2003 compiles for). In .NEt 1.1 you can perform validation by using XmlValidatingReader

    See: Validation Types of the XmlValidatingReader
    http://msdn2.microsoft.com/en-us/library/yes0wd1w(VS.71).aspx

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: code not work 2003

    03-03-2008, 11:59 AM
    • Participant
      792 point Participant
    • hong_ma
    • Member since 05-10-2005, 2:05 PM
    • Posts 194

    after I change code to  

    XmlTextReader tr = new XmlTextReader(response.GetResponseStream()); //
            XmlValidatingReader vr = new XmlValidatingReader(tr);
                    vr.ValidationType = ValidationType.Auto;
        XmlDocument document = new XmlDocument();
        document.Load(vr);
        response.Close();

    I got the error, I don't why, Thanks.
    {"Could not find a part of the path \"C:\\WINDOWS\\system32\\dtd\\error.dtd\"." }

  • Re: code not work 2003

    03-04-2008, 11:37 AM
    • All-Star
      46,040 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Check the path the document is tried to load from. This tries to say you load it with relative path when the root is assumed to be system folder. If you're in ASP.NET, you can use Server.MapPath to make it physical path (but does the error come fro n there or from searching the DTD based on the doc?).

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: code not work 2003

    03-04-2008, 1:43 PM
    • Participant
      792 point Participant
    • hong_ma
    • Member since 05-10-2005, 2:05 PM
    • Posts 194


    the error message from line  document.Load(vr);
    that means error message from searching the DTD based on the doc.

    in 2005 it works, because  we used
    XmlReaderSettings settings = new XmlReaderSettings();
    settings.ProhibitDtd = false;
    settings.XmlResolver = null;

     We need to use these settings to tell the parser not to get the
            dtd.  The web service returns a dtd link in the document -
            we do NOT want to parse this!.
    but in 2003, I don't how to do that. Thanks.

  • Re: code not work 2003

    03-04-2008, 3:06 PM
    • All-Star
      46,040 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Well,

    if you have DTD there and you're using validating reader with Auto, it will try to use the DTD (see the links I posted). By setting     

    vr.ValidationType = ValidationType.None;

    it wouldn't try to validate.

    But why even use validating reader in first place, if you don't want to validate?

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: code not work 2003

    03-04-2008, 4:02 PM
    • Participant
      792 point Participant
    • hong_ma
    • Member since 05-10-2005, 2:05 PM
    • Posts 194

    Because when I used the code below, I get same error message which is "Could not find a part of the path \"C:\\WINDOWS\\system32\\dtd\\error.dtd"

    that's why I used  validate. after I changed the  vr.ValidationType = ValidationType.None; it still got same error message, Thanks.

    XmlTextReader tr = new XmlTextReader(response.GetResponseStream()); //

    // XmlValidatingReader vr = new XmlValidatingReader(tr);

    // vr.ValidationType = ValidationType.None;

    XmlDocument document = new XmlDocument();

    document.Load(tr);

    response.Close();

  • Re: code not work 2003

    03-05-2008, 4:19 PM
    • Participant
      792 point Participant
    • hong_ma
    • Member since 05-10-2005, 2:05 PM
    • Posts 194

    That's what I thought. maybe it's not a code issue. because my computer should have a
    file in C:\\WINDOWS\\system32\\dtd\\error.dtd. but I am not sure.

Page 1 of 1 (8 items)