Professional Web Applications Themes

ASP Coding Problem, XMLDOM-related (or just language-related!) - ASP Components

Hi, I'm hoping someone can help me with this problem. I'm not sure whether the problem lies with the software or with my understanding of the language. I'm using the Microsoft.XMLDOM object in an ASP page to read an incoming XML post request and respond to it. Although the XMLDOM object verifies the XML at a basic level, I want to make sure that the request is in the correct format (as per the specification I have to work to), as well as making sure that any XML at all was sent successfully. At the moment, I'm stuck at the ...

  1. #1

    Default ASP Coding Problem, XMLDOM-related (or just language-related!)

    Hi,

    I'm hoping someone can help me with this problem. I'm not sure whether
    the problem lies with the software or with my understanding of the
    language.

    I'm using the Microsoft.XMLDOM object in an ASP page to read an
    incoming XML post request and respond to it. Although the XMLDOM
    object verifies the XML at a basic level, I want to make sure that the
    request is in the correct format (as per the specification I have to
    work to), as well as making sure that any XML at all was sent
    successfully.

    At the moment, I'm stuck at the point of just trying to make sure that
    an XML request was sent at all. Here's the code I'm using.. (note that
    I'm loading the XML from a file for ease-of-testing, but am giving a
    bad filename so as to create the condition where the XML didn't load
    successfully):

    ...<body>
    <%
    Dim xmlDoc
    Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    xmlDoc.Load ("C:\file_that_doesn't_exist.xml")
    'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    If Not isNull(xmlDoc.doentElement) Then ' conditional
    Response.Write xmlDoc.doentElement.nodeName
    End If
    %>
    </body>..

    From Microsoft's DOM reference, for the 'doentElement' property
    ([url]http://msdn2.microsoft.com/en-us/library/ms759095.aspx):[/url]

    "The property is read/write. It returns an IXMLDOMElement that
    represents the single element that represents the root of the XML
    doent tree. It returns Null if no root exists."

    The problem is that doentElement doesn't seem to be returning Null,
    or at least the method I'm using to evaluate it is drawing the wrong
    conclusion, and so the Response.Write line is always executed, and
    causes an 'Object required' error on that line. (Since, I assume, it's
    attempting to call 'nodeName' on a null 'doentElement')

    I've tried changing the condition to:

    If xmlDoc.doentElement <> Null Then

    But this causes its own 'Object required' error. I've also tried
    assigning the property to a variable using Set and testing the
    variable, and other various variations but all to no avail!

    Any comments/suggestions/corrections are extremely welcome, although
    I'm looking for a way to make the conditional work as it should rather
    than some other way of checking that the XML was sent properly, as I
    have a more complete block of parsing code that runs into exactly the
    same problem later on when checking for the existence of text values
    for XML nodes.

    Many thanks,

    -Jon L


    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Jon L Guest

  2. #2

    Default Re: ASP Coding Problem, XMLDOM-related (or just language-related!)

    shouldn't that be ...
    > ..<body>
    > <%
    > Dim xmlDoc
    > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    if xmlDoc.Load ("C:\file_that_doesn't_exist.xml") then
    > 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    > If Not isNull(xmlDoc.doentElement) Then ' conditional
    > Response.Write xmlDoc.doentElement.nodeName
    > End If
    else
    response.write "unable to load .."
    end if
    > %>
    > </body>..
    David Bray
    [url]http://www[/url] - dot - brayworth - dot - com - dot - au
    david - at - brayworth - dot - com - dot - au

    /*
    This email is but an indication and in no
    way a complete and/or faithful statement.
    */

    Jon L wrote:
    > Hi,
    >
    > I'm hoping someone can help me with this problem. I'm not sure whether
    > the problem lies with the software or with my understanding of the
    > language.
    >
    > I'm using the Microsoft.XMLDOM object in an ASP page to read an
    > incoming XML post request and respond to it. Although the XMLDOM
    > object verifies the XML at a basic level, I want to make sure that the
    > request is in the correct format (as per the specification I have to
    > work to), as well as making sure that any XML at all was sent
    > successfully.
    >
    > At the moment, I'm stuck at the point of just trying to make sure that
    > an XML request was sent at all. Here's the code I'm using.. (note that
    > I'm loading the XML from a file for ease-of-testing, but am giving a
    > bad filename so as to create the condition where the XML didn't load
    > successfully):
    >
    > ..<body>
    > <%
    > Dim xmlDoc
    > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    > xmlDoc.Load ("C:\file_that_doesn't_exist.xml")
    > 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    > If Not isNull(xmlDoc.doentElement) Then ' conditional
    > Response.Write xmlDoc.doentElement.nodeName
    > End If
    > %>
    > </body>..
    >
    > From Microsoft's DOM reference, for the 'doentElement' property
    > ([url]http://msdn2.microsoft.com/en-us/library/ms759095.aspx):[/url]
    >
    > "The property is read/write. It returns an IXMLDOMElement that
    > represents the single element that represents the root of the XML
    > doent tree. It returns Null if no root exists."
    >
    > The problem is that doentElement doesn't seem to be returning Null,
    > or at least the method I'm using to evaluate it is drawing the wrong
    > conclusion, and so the Response.Write line is always executed, and
    > causes an 'Object required' error on that line. (Since, I assume, it's
    > attempting to call 'nodeName' on a null 'doentElement')
    >
    > I've tried changing the condition to:
    >
    > If xmlDoc.doentElement <> Null Then
    >
    > But this causes its own 'Object required' error. I've also tried
    > assigning the property to a variable using Set and testing the
    > variable, and other various variations but all to no avail!
    >
    > Any comments/suggestions/corrections are extremely welcome, although
    > I'm looking for a way to make the conditional work as it should rather
    > than some other way of checking that the XML was sent properly, as I
    > have a more complete block of parsing code that runs into exactly the
    > same problem later on when checking for the existence of text values
    > for XML nodes.
    >
    > Many thanks,
    >
    > -Jon L
    >
    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    > [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    > ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Dave Guest

  3. #3

    Default Re: ASP Coding Problem, XMLDOM-related (or just language-related!)

    Yes that does fix the immediate problem, removing the need to check
    the doentElement property for Null at all, but not the problem that
    I run into later in the parsing code which is of a similar nature.

    To demonstrate this:

    <%
    Dim xmlDoc
    Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    If xmlDoc.Load ("C:\foo.xml") Then
    Response.Write xmlDoc.doentElement.nodeName
    If Not isNull(xmlDoc.doentElement.firstChild) Then ' check
    Response.Write xmlDoc.doentElement.firstChild.nodeValue
    End If
    Else
    Response.Write "Could not load the file"
    End If
    %>

    ------- foo.xml -------
    <?xml version="1.0"?>
    <foo></foo>
    ----- end foo.xml -----

    The firstChild property for doentElement should return Null as per
    [url]http://msdn2.microsoft.com/en-us/library/ms753823.aspx[/url], as the 'foo'
    tag is empty, but execution of the code above sails past the line
    marked 'check' to execute the next line and cause another 'Object
    required' error. I have no idea why this happens, but I guess that
    either the object isn't returning Null as promised, or the IsNull
    function isn't the correct check to use here (although, again, I've
    tried checking for equality with Null as well).

    Any further insight welcome.

    Cheers,

    -Jon L

    On Fri, 12 Jan 2007 09:37:08 +1000, Dave <davenowhere.com> wrote:
    >shouldn't that be ...
    >
    > > ..<body>
    > > <%
    > > Dim xmlDoc
    > > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >
    >if xmlDoc.Load ("C:\file_that_doesn't_exist.xml") then
    >
    > > 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    > > If Not isNull(xmlDoc.doentElement) Then ' conditional
    > > Response.Write xmlDoc.doentElement.nodeName
    > > End If
    >
    >else
    > response.write "unable to load .."
    >end if
    >
    > > %>
    > > </body>..
    >
    >David Bray
    >[url]http://www[/url] - dot - brayworth - dot - com - dot - au
    >david - at - brayworth - dot - com - dot - au
    >
    >/*
    > This email is but an indication and in no
    > way a complete and/or faithful statement.
    >*/
    >
    >Jon L wrote:
    >> Hi,
    >>
    >> I'm hoping someone can help me with this problem. I'm not sure whether
    >> the problem lies with the software or with my understanding of the
    >> language.
    >>
    >> I'm using the Microsoft.XMLDOM object in an ASP page to read an
    >> incoming XML post request and respond to it. Although the XMLDOM
    >> object verifies the XML at a basic level, I want to make sure that the
    >> request is in the correct format (as per the specification I have to
    >> work to), as well as making sure that any XML at all was sent
    >> successfully.
    >>
    >> At the moment, I'm stuck at the point of just trying to make sure that
    >> an XML request was sent at all. Here's the code I'm using.. (note that
    >> I'm loading the XML from a file for ease-of-testing, but am giving a
    >> bad filename so as to create the condition where the XML didn't load
    >> successfully):
    >>
    >> ..<body>
    >> <%
    >> Dim xmlDoc
    >> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >> xmlDoc.Load ("C:\file_that_doesn't_exist.xml")
    >> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    >> If Not isNull(xmlDoc.doentElement) Then ' conditional
    >> Response.Write xmlDoc.doentElement.nodeName
    >> End If
    >> %>
    >> </body>..
    >>
    >> From Microsoft's DOM reference, for the 'doentElement' property
    >> ([url]http://msdn2.microsoft.com/en-us/library/ms759095.aspx):[/url]
    >>
    >> "The property is read/write. It returns an IXMLDOMElement that
    >> represents the single element that represents the root of the XML
    >> doent tree. It returns Null if no root exists."
    >>
    >> The problem is that doentElement doesn't seem to be returning Null,
    >> or at least the method I'm using to evaluate it is drawing the wrong
    >> conclusion, and so the Response.Write line is always executed, and
    >> causes an 'Object required' error on that line. (Since, I assume, it's
    >> attempting to call 'nodeName' on a null 'doentElement')
    >>
    >> I've tried changing the condition to:
    >>
    >> If xmlDoc.doentElement <> Null Then
    >>
    >> But this causes its own 'Object required' error. I've also tried
    >> assigning the property to a variable using Set and testing the
    >> variable, and other various variations but all to no avail!
    >>
    >> Any comments/suggestions/corrections are extremely welcome, although
    >> I'm looking for a way to make the conditional work as it should rather
    >> than some other way of checking that the XML was sent properly, as I
    >> have a more complete block of parsing code that runs into exactly the
    >> same problem later on when checking for the existence of text values
    >> for XML nodes.
    >>
    >> Many thanks,
    >>
    >> -Jon L
    >>
    >>
    >> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    >> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    >> ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Jon L Guest

  4. #4

    Default Re: ASP Coding Problem, XMLDOM-related (or just language-related!)

    How about
    > <%
    > Dim xmlDoc
    > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    > If xmlDoc.Load ("C:\foo.xml") Then
    > Response.Write xmlDoc.doentElement.nodeName
    If Not xmlDoc.doentElement.firstChild is nothing Then ' check
    > Response.Write xmlDoc.doentElement.firstChild.nodeValue
    > End If
    > Else
    > Response.Write "Could not load the file"
    > End If
    > %>
    David Bray
    [url]http://www[/url] - dot - brayworth - dot - com - dot - au
    david - at - brayworth - dot - com - dot - au

    /*
    This email is but an indication and in no
    way a complete and/or faithful statement.
    */

    Jon L wrote:
    > Yes that does fix the immediate problem, removing the need to check
    > the doentElement property for Null at all, but not the problem that
    > I run into later in the parsing code which is of a similar nature.
    >
    > To demonstrate this:
    >
    > <%
    > Dim xmlDoc
    > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    > If xmlDoc.Load ("C:\foo.xml") Then
    > Response.Write xmlDoc.doentElement.nodeName
    > If Not isNull(xmlDoc.doentElement.firstChild) Then ' check
    > Response.Write xmlDoc.doentElement.firstChild.nodeValue
    > End If
    > Else
    > Response.Write "Could not load the file"
    > End If
    > %>
    >
    > ------- foo.xml -------
    > <?xml version="1.0"?>
    > <foo></foo>
    > ----- end foo.xml -----
    >
    > The firstChild property for doentElement should return Null as per
    > [url]http://msdn2.microsoft.com/en-us/library/ms753823.aspx[/url], as the 'foo'
    > tag is empty, but execution of the code above sails past the line
    > marked 'check' to execute the next line and cause another 'Object
    > required' error. I have no idea why this happens, but I guess that
    > either the object isn't returning Null as promised, or the IsNull
    > function isn't the correct check to use here (although, again, I've
    > tried checking for equality with Null as well).
    >
    > Any further insight welcome.
    >
    > Cheers,
    >
    > -Jon L
    >
    > On Fri, 12 Jan 2007 09:37:08 +1000, Dave <davenowhere.com> wrote:
    >
    >> shouldn't that be ...
    >>
    >>> ..<body>
    >>> <%
    >>> Dim xmlDoc
    >>> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >> if xmlDoc.Load ("C:\file_that_doesn't_exist.xml") then
    >>
    >>> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    >>> If Not isNull(xmlDoc.doentElement) Then ' conditional
    >>> Response.Write xmlDoc.doentElement.nodeName
    >>> End If
    >> else
    >> response.write "unable to load .."
    >> end if
    >>
    >>> %>
    >>> </body>..
    >> David Bray
    >> [url]http://www[/url] - dot - brayworth - dot - com - dot - au
    >> david - at - brayworth - dot - com - dot - au
    >>
    >> /*
    >> This email is but an indication and in no
    >> way a complete and/or faithful statement.
    >> */
    >>
    >> Jon L wrote:
    >>> Hi,
    >>>
    >>> I'm hoping someone can help me with this problem. I'm not sure whether
    >>> the problem lies with the software or with my understanding of the
    >>> language.
    >>>
    >>> I'm using the Microsoft.XMLDOM object in an ASP page to read an
    >>> incoming XML post request and respond to it. Although the XMLDOM
    >>> object verifies the XML at a basic level, I want to make sure that the
    >>> request is in the correct format (as per the specification I have to
    >>> work to), as well as making sure that any XML at all was sent
    >>> successfully.
    >>>
    >>> At the moment, I'm stuck at the point of just trying to make sure that
    >>> an XML request was sent at all. Here's the code I'm using.. (note that
    >>> I'm loading the XML from a file for ease-of-testing, but am giving a
    >>> bad filename so as to create the condition where the XML didn't load
    >>> successfully):
    >>>
    >>> ..<body>
    >>> <%
    >>> Dim xmlDoc
    >>> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >>> xmlDoc.Load ("C:\file_that_doesn't_exist.xml")
    >>> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    >>> If Not isNull(xmlDoc.doentElement) Then ' conditional
    >>> Response.Write xmlDoc.doentElement.nodeName
    >>> End If
    >>> %>
    >>> </body>..
    >>>
    >>> From Microsoft's DOM reference, for the 'doentElement' property
    >>> ([url]http://msdn2.microsoft.com/en-us/library/ms759095.aspx):[/url]
    >>>
    >>> "The property is read/write. It returns an IXMLDOMElement that
    >>> represents the single element that represents the root of the XML
    >>> doent tree. It returns Null if no root exists."
    >>>
    >>> The problem is that doentElement doesn't seem to be returning Null,
    >>> or at least the method I'm using to evaluate it is drawing the wrong
    >>> conclusion, and so the Response.Write line is always executed, and
    >>> causes an 'Object required' error on that line. (Since, I assume, it's
    >>> attempting to call 'nodeName' on a null 'doentElement')
    >>>
    >>> I've tried changing the condition to:
    >>>
    >>> If xmlDoc.doentElement <> Null Then
    >>>
    >>> But this causes its own 'Object required' error. I've also tried
    >>> assigning the property to a variable using Set and testing the
    >>> variable, and other various variations but all to no avail!
    >>>
    >>> Any comments/suggestions/corrections are extremely welcome, although
    >>> I'm looking for a way to make the conditional work as it should rather
    >>> than some other way of checking that the XML was sent properly, as I
    >>> have a more complete block of parsing code that runs into exactly the
    >>> same problem later on when checking for the existence of text values
    >>> for XML nodes.
    >>>
    >>> Many thanks,
    >>>
    >>> -Jon L
    >>>
    >>>
    >>> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    >>> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    >>> ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    >
    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    > [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    > ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Dave Guest

  5. #5

    Default Re: ASP Coding Problem, XMLDOM-related (or just language-related!)


    "Jon L" <not_puttingmy.email.on.usenet.thanks> wrote in message
    news:8c4dq25m0qf03qso8b285ojku10a73pvhh4ax.com...
    > Hi,
    >
    > I'm hoping someone can help me with this problem. I'm not sure whether
    > the problem lies with the software or with my understanding of the
    > language.
    >
    > I'm using the Microsoft.XMLDOM object in an ASP page to read an
    > incoming XML post request and respond to it. Although the XMLDOM
    > object verifies the XML at a basic level, I want to make sure that the
    > request is in the correct format (as per the specification I have to
    > work to), as well as making sure that any XML at all was sent
    > successfully.
    >
    > At the moment, I'm stuck at the point of just trying to make sure that
    > an XML request was sent at all. Here's the code I'm using.. (note that
    > I'm loading the XML from a file for ease-of-testing, but am giving a
    > bad filename so as to create the condition where the XML didn't load
    > successfully):
    >
    > ..<body>
    > <%
    > Dim xmlDoc
    > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    > xmlDoc.Load ("C:\file_that_doesn't_exist.xml")
    > 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    > If Not isNull(xmlDoc.doentElement) Then ' conditional
    > Response.Write xmlDoc.doentElement.nodeName
    > End If
    > %>
    > </body>..
    >
    > From Microsoft's DOM reference, for the 'doentElement' property
    > ([url]http://msdn2.microsoft.com/en-us/library/ms759095.aspx):[/url]
    >
    > "The property is read/write. It returns an IXMLDOMElement that
    > represents the single element that represents the root of the XML
    > doent tree. It returns Null if no root exists."
    >
    > The problem is that doentElement doesn't seem to be returning Null,
    > or at least the method I'm using to evaluate it is drawing the wrong
    > conclusion, and so the Response.Write line is always executed, and
    > causes an 'Object required' error on that line. (Since, I assume, it's
    > attempting to call 'nodeName' on a null 'doentElement')
    >
    > I've tried changing the condition to:
    >
    > If xmlDoc.doentElement <> Null Then
    >
    > But this causes its own 'Object required' error. I've also tried
    > assigning the property to a variable using Set and testing the
    > variable, and other various variations but all to no avail!
    >
    > Any comments/suggestions/corrections are extremely welcome, although
    > I'm looking for a way to make the conditional work as it should rather
    > than some other way of checking that the XML was sent properly, as I
    > have a more complete block of parsing code that runs into exactly the
    > same problem later on when checking for the existence of text values
    > for XML nodes.
    >
    > Many thanks,
    >
    > -Jon L
    >
    Here is code I use to receive an XML post:-

    Dim oDOM: Set oDOM = Server.CreateObject("MSXML2.DOMDoent.3.0")
    oDOM.async = False
    oDOM.load Request

    'Assert XML loaded
    If oDOM.pError.number <> 0 Then
    'Exception code here
    'End response
    End If

    ' Processing of XML doent can continue

    A couple of other things:-

    Don't use 'Microsoft.XMLDOM' since there's no way to be sure what you are
    going to get, use a version specific ProgID instead. As above.

    Null in VBScript is not equivalent to a Null object pointer which is instead
    called Nothing VB speak.


    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
    News==----
    > [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+
    Newsgroups
    > ----= East and West-Coast Server Farms - Total Privacy via Encryption
    =----


    Anthony Jones Guest

  6. #6

    Default Re: ASP Coding Problem, XMLDOM-related (or just language-related!)

    That does it, thanks! the "If Not ... Is Nothing" syntax is what I was
    missing.

    Cheers,

    -Jon L

    On Fri, 12 Jan 2007 13:24:18 +1000, Dave <davenowhere.com> wrote:
    >How about
    >
    > > <%
    > > Dim xmlDoc
    > > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    > > If xmlDoc.Load ("C:\foo.xml") Then
    > > Response.Write xmlDoc.doentElement.nodeName
    >
    >If Not xmlDoc.doentElement.firstChild is nothing Then ' check
    >
    > > Response.Write xmlDoc.doentElement.firstChild.nodeValue
    > > End If
    > > Else
    > > Response.Write "Could not load the file"
    > > End If
    > > %>
    >
    >David Bray
    >[url]http://www[/url] - dot - brayworth - dot - com - dot - au
    >david - at - brayworth - dot - com - dot - au
    >
    >/*
    > This email is but an indication and in no
    > way a complete and/or faithful statement.
    >*/
    >
    >Jon L wrote:
    >> Yes that does fix the immediate problem, removing the need to check
    >> the doentElement property for Null at all, but not the problem that
    >> I run into later in the parsing code which is of a similar nature.
    >>
    >> To demonstrate this:
    >>
    >> <%
    >> Dim xmlDoc
    >> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >> If xmlDoc.Load ("C:\foo.xml") Then
    >> Response.Write xmlDoc.doentElement.nodeName
    >> If Not isNull(xmlDoc.doentElement.firstChild) Then ' check
    >> Response.Write xmlDoc.doentElement.firstChild.nodeValue
    >> End If
    >> Else
    >> Response.Write "Could not load the file"
    >> End If
    >> %>
    >>
    >> ------- foo.xml -------
    >> <?xml version="1.0"?>
    >> <foo></foo>
    >> ----- end foo.xml -----
    >>
    >> The firstChild property for doentElement should return Null as per
    >> [url]http://msdn2.microsoft.com/en-us/library/ms753823.aspx[/url], as the 'foo'
    >> tag is empty, but execution of the code above sails past the line
    >> marked 'check' to execute the next line and cause another 'Object
    >> required' error. I have no idea why this happens, but I guess that
    >> either the object isn't returning Null as promised, or the IsNull
    >> function isn't the correct check to use here (although, again, I've
    >> tried checking for equality with Null as well).
    >>
    >> Any further insight welcome.
    >>
    >> Cheers,
    >>
    >> -Jon L
    >>
    >> On Fri, 12 Jan 2007 09:37:08 +1000, Dave <davenowhere.com> wrote:
    >>
    >>> shouldn't that be ...
    >>>
    >>>> ..<body>
    >>>> <%
    >>>> Dim xmlDoc
    >>>> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >>> if xmlDoc.Load ("C:\file_that_doesn't_exist.xml") then
    >>>
    >>>> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    >>>> If Not isNull(xmlDoc.doentElement) Then ' conditional
    >>>> Response.Write xmlDoc.doentElement.nodeName
    >>>> End If
    >>> else
    >>> response.write "unable to load .."
    >>> end if
    >>>
    >>>> %>
    >>>> </body>..
    >>> David Bray
    >>> [url]http://www[/url] - dot - brayworth - dot - com - dot - au
    >>> david - at - brayworth - dot - com - dot - au
    >>>
    >>> /*
    >>> This email is but an indication and in no
    >>> way a complete and/or faithful statement.
    >>> */
    >>>
    >>> Jon L wrote:
    >>>> Hi,
    >>>>
    >>>> I'm hoping someone can help me with this problem. I'm not sure whether
    >>>> the problem lies with the software or with my understanding of the
    >>>> language.
    >>>>
    >>>> I'm using the Microsoft.XMLDOM object in an ASP page to read an
    >>>> incoming XML post request and respond to it. Although the XMLDOM
    >>>> object verifies the XML at a basic level, I want to make sure that the
    >>>> request is in the correct format (as per the specification I have to
    >>>> work to), as well as making sure that any XML at all was sent
    >>>> successfully.
    >>>>
    >>>> At the moment, I'm stuck at the point of just trying to make sure that
    >>>> an XML request was sent at all. Here's the code I'm using.. (note that
    >>>> I'm loading the XML from a file for ease-of-testing, but am giving a
    >>>> bad filename so as to create the condition where the XML didn't load
    >>>> successfully):
    >>>>
    >>>> ..<body>
    >>>> <%
    >>>> Dim xmlDoc
    >>>> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
    >>>> xmlDoc.Load ("C:\file_that_doesn't_exist.xml")
    >>>> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
    >>>> If Not isNull(xmlDoc.doentElement) Then ' conditional
    >>>> Response.Write xmlDoc.doentElement.nodeName
    >>>> End If
    >>>> %>
    >>>> </body>..
    >>>>
    >>>> From Microsoft's DOM reference, for the 'doentElement' property
    >>>> ([url]http://msdn2.microsoft.com/en-us/library/ms759095.aspx):[/url]
    >>>>
    >>>> "The property is read/write. It returns an IXMLDOMElement that
    >>>> represents the single element that represents the root of the XML
    >>>> doent tree. It returns Null if no root exists."
    >>>>
    >>>> The problem is that doentElement doesn't seem to be returning Null,
    >>>> or at least the method I'm using to evaluate it is drawing the wrong
    >>>> conclusion, and so the Response.Write line is always executed, and
    >>>> causes an 'Object required' error on that line. (Since, I assume, it's
    >>>> attempting to call 'nodeName' on a null 'doentElement')
    >>>>
    >>>> I've tried changing the condition to:
    >>>>
    >>>> If xmlDoc.doentElement <> Null Then
    >>>>
    >>>> But this causes its own 'Object required' error. I've also tried
    >>>> assigning the property to a variable using Set and testing the
    >>>> variable, and other various variations but all to no avail!
    >>>>
    >>>> Any comments/suggestions/corrections are extremely welcome, although
    >>>> I'm looking for a way to make the conditional work as it should rather
    >>>> than some other way of checking that the XML was sent properly, as I
    >>>> have a more complete block of parsing code that runs into exactly the
    >>>> same problem later on when checking for the existence of text values
    >>>> for XML nodes.
    >>>>
    >>>> Many thanks,
    >>>>
    >>>> -Jon L
    >>>>
    >>>>
    >>>> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    >>>> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    >>>> ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    >>
    >>
    >> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    >> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    >> ----= East and West-Coast Server Farms - Total Privacy via Encryption =----

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Jon L Guest

Similar Threads

  1. Problem related to flash player installation
    By deepanjan@imedea in forum Macromedia Flash Player
    Replies: 0
    Last Post: August 16th, 09:39 AM
  2. 3 Drop Downs Related Problem ...
    By jce1975 in forum Macromedia ColdFusion
    Replies: 1
    Last Post: March 9th, 01:08 AM
  3. Bit of a newbie problem - SqlWebAdmin Related.....
    By martin c in forum ASP.NET Web Services
    Replies: 0
    Last Post: November 18th, 09:29 PM
  4. HDR related problem
    By antzz in forum Informix
    Replies: 0
    Last Post: September 8th, 02:58 PM
  5. problem related to Temporary Internet files
    By Tin in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: August 4th, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139