Ask a Question related to ASP Components, Design and Development.
-
Jon L #1
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.documentElement) Then ' conditional
Response.Write xmlDoc.documentElement.nodeName
End If
%>
</body>..
From Microsoft's DOM reference, for the 'documentElement' 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
document tree. It returns Null if no root exists."
The problem is that documentElement 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 'documentElement')
I've tried changing the condition to:
If xmlDoc.documentElement <> 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
-
Problem related to flash player installation
Hi, I did not actually face a trouble in installing flash player 9 for Netscape related browsers. The problem is that I am unable to see a... -
Problem with CF dying when related servers under load
We have been dealing with a problem involving a CF server, a SQL server and a Verity server. When either the SQL server or the Verity Server is... -
3 Drop Downs Related Problem ...
I am working on getting three drop downs to auto populate based upon the prior selection. I have gotten this to work, however, my client wants an... -
Bit of a newbie problem - SqlWebAdmin Related.....
Hi All I am currently trying (With fairly solid Incompetence) to customize / modify the microsoft SqlWebAdmin tool. Anyone familiar with it? ... -
HDR related problem
I have HDR running on an IDS 7.31 on SCO Unix 5.0.5. I took a Level 0 backup of my Primary, did some transactions which were replicated to my... -
Dave #2
Re: ASP Coding Problem, XMLDOM-related (or just language-related!)
shouldn't that be ...
if xmlDoc.Load ("C:\file_that_doesn't_exist.xml") then> ..<body>
> <%
> Dim xmlDoc
> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
else> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
> If Not isNull(xmlDoc.documentElement) Then ' conditional
> Response.Write xmlDoc.documentElement.nodeName
> End If
response.write "unable to load .."
end if
David Bray> %>
> </body>..
[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.documentElement) Then ' conditional
> Response.Write xmlDoc.documentElement.nodeName
> End If
> %>
> </body>..
>
> From Microsoft's DOM reference, for the 'documentElement' 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
> document tree. It returns Null if no root exists."
>
> The problem is that documentElement 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 'documentElement')
>
> I've tried changing the condition to:
>
> If xmlDoc.documentElement <> 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
-
Jon L #3
Re: ASP Coding Problem, XMLDOM-related (or just language-related!)
Yes that does fix the immediate problem, removing the need to check
the documentElement 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.documentElement.nodeName
If Not isNull(xmlDoc.documentElement.firstChild) Then ' check
Response.Write xmlDoc.documentElement.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 documentElement 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 <dave@nowhere.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.documentElement) Then ' conditional
> > Response.Write xmlDoc.documentElement.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.documentElement) Then ' conditional
>> Response.Write xmlDoc.documentElement.nodeName
>> End If
>> %>
>> </body>..
>>
>> From Microsoft's DOM reference, for the 'documentElement' 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
>> document tree. It returns Null if no root exists."
>>
>> The problem is that documentElement 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 'documentElement')
>>
>> I've tried changing the condition to:
>>
>> If xmlDoc.documentElement <> 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
-
Dave #4
Re: ASP Coding Problem, XMLDOM-related (or just language-related!)
How about
If Not xmlDoc.documentElement.firstChild is nothing Then ' check> <%
> Dim xmlDoc
> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
> If xmlDoc.Load ("C:\foo.xml") Then
> Response.Write xmlDoc.documentElement.nodeName
David Bray> Response.Write xmlDoc.documentElement.firstChild.nodeValue
> End If
> Else
> Response.Write "Could not load the file"
> End If
> %>
[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 documentElement 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.documentElement.nodeName
> If Not isNull(xmlDoc.documentElement.firstChild) Then ' check
> Response.Write xmlDoc.documentElement.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 documentElement 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 <dave@nowhere.com> wrote:
>>>> shouldn't that be ...
>>>> if xmlDoc.Load ("C:\file_that_doesn't_exist.xml") then>>> ..<body>
>>> <%
>>> Dim xmlDoc
>>> Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
>>>> else>>> 'xmlDoc.Load ("C:\InetPub\wwwroot\foo.xml")
>>> If Not isNull(xmlDoc.documentElement) Then ' conditional
>>> Response.Write xmlDoc.documentElement.nodeName
>>> End If
>> response.write "unable to load .."
>> end if
>>>> David Bray>>> %>
>>> </body>..
>> [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.documentElement) Then ' conditional
>>> Response.Write xmlDoc.documentElement.nodeName
>>> End If
>>> %>
>>> </body>..
>>>
>>> From Microsoft's DOM reference, for the 'documentElement' 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
>>> document tree. It returns Null if no root exists."
>>>
>>> The problem is that documentElement 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 'documentElement')
>>>
>>> I've tried changing the condition to:
>>>
>>> If xmlDoc.documentElement <> 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
-
Anthony Jones #5
Re: ASP Coding Problem, XMLDOM-related (or just language-related!)
"Jon L" <not_putting@my.email.on.usenet.thanks> wrote in message
news:8c4dq25m0qf03qso8b285ojku10a73pvhh@4ax.com...Here is code I use to receive an XML post:-> 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.documentElement) Then ' conditional
> Response.Write xmlDoc.documentElement.nodeName
> End If
> %>
> </body>..
>
> From Microsoft's DOM reference, for the 'documentElement' 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
> document tree. It returns Null if no root exists."
>
> The problem is that documentElement 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 'documentElement')
>
> I've tried changing the condition to:
>
> If xmlDoc.documentElement <> 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
>
Dim oDOM: Set oDOM = Server.CreateObject("MSXML2.DOMDocument.3.0")
oDOM.async = False
oDOM.load Request
'Assert XML loaded
If oDOM.parseError.number <> 0 Then
'Exception code here
'End response
End If
' Processing of XML document 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.
News==---->
> ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure UsenetNewsgroups> [url]http://www.newsfeeds.com[/url] The #1 Newsgroup Service in the World! 120,000+=----> ----= East and West-Coast Server Farms - Total Privacy via Encryption
Anthony Jones Guest
-
Jon L #6
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 <dave@nowhere.com> wrote:
>How about
>>> > <%
> > Dim xmlDoc
> > Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
> > If xmlDoc.Load ("C:\foo.xml") Then
> > Response.Write xmlDoc.documentElement.nodeName
>If Not xmlDoc.documentElement.firstChild is nothing Then ' check
>>> > Response.Write xmlDoc.documentElement.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 documentElement 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.documentElement.nodeName
>> If Not isNull(xmlDoc.documentElement.firstChild) Then ' check
>> Response.Write xmlDoc.documentElement.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 documentElement 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 <dave@nowhere.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.documentElement) Then ' conditional
>>>> Response.Write xmlDoc.documentElement.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.documentElement) Then ' conditional
>>>> Response.Write xmlDoc.documentElement.nodeName
>>>> End If
>>>> %>
>>>> </body>..
>>>>
>>>> From Microsoft's DOM reference, for the 'documentElement' 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
>>>> document tree. It returns Null if no root exists."
>>>>
>>>> The problem is that documentElement 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 'documentElement')
>>>>
>>>> I've tried changing the condition to:
>>>>
>>>> If xmlDoc.documentElement <> 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



Reply With Quote

