Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Request help parsing XML reply from HTTPRequest

Reply
Thread Tools

Request help parsing XML reply from HTTPRequest

 
 
Bart Van der Donck
Guest
Posts: n/a
 
      09-26-2007
Thomas 'PointedEars' Lahn wrote:

> Doug Miller wrote:
>
>> I guess this is where I'm really lost: How can I "serve the response
>> declared with an XML media type in its Content-Type header" when I have
>> no control over what comes back from the server?

>
> Ask the person that is administrating the server to serve the document
> with a proper media type so that you can make use of it.


Good chance that there's no need for that.

To the original poster: could you try to upload a file named .htaccess
into the same directory with the following content:

AddType text/xml xml

Works when you're on UNIX and allowed to use directives.

--
Bart

 
Reply With Quote
 
 
 
 
Doug Miller
Guest
Posts: n/a
 
      09-26-2007
In article <(E-Mail Removed)>, Thomas 'PointedEars' Lahn <(E-Mail Removed)> wrote:
>Doug Miller wrote:
>> In article <(E-Mail Removed)>, Thomas 'PointedEars' Lahn

> <(E-Mail Removed)> wrote:
>>> Ask the person that is administrating the server to serve the document with
>>> a proper media type so that you can make use of it.

>>
>> Unfortunately that is not an option.

>
>Why that would be so is beyond me; you could at least try to convince them
>to improve the quality of their service. Unless you are using their service
>without authorization, of course.


The service I am using is the United States Postal Service Rate Calculation
API -- *with* authorization, thank you very much.

How successful do you suppose I'm going to be at convincing them that they
need to change anything?

--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.
 
Reply With Quote
 
 
 
 
Doug Miller
Guest
Posts: n/a
 
      09-26-2007
In article <(E-Mail Removed) .com>, Bart Van der Donck <(E-Mail Removed)> wrote:
>To the original poster: could you try to upload a file named .htaccess
>into the same directory with the following content:
>
> AddType text/xml xml


Did that; no effect.
>
>Works when you're on UNIX and allowed to use directives.


I'm on Windows XP Pro, using IE6 (testing this from my desktop PC before
attempting to upload to a web server).


--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      09-26-2007
Doug Miller wrote:
> [...] Thomas 'PointedEars' Lahn <(E-Mail Removed)> wrote:
>> Doug Miller wrote:
>>> In article <(E-Mail Removed)>, Thomas 'PointedEars' Lahn

>> <(E-Mail Removed)> wrote:
>>>> Ask the person that is administrating the server to serve the document with
>>>> a proper media type so that you can make use of it.
>>> Unfortunately that is not an option.

>> Why that would be so is beyond me; you could at least try to convince them
>> to improve the quality of their service. Unless you are using their service
>> without authorization, of course.

>
> The service I am using is the United States Postal Service Rate Calculation
> API -- *with* authorization, thank you very much.


ACK

> How successful do you suppose I'm going to be at convincing them that they
> need to change anything?


Come on, you have not even tried.

But even if you could not, you could use server-side scripting on your
server to retrieve the resource unchanged from their server and then serve
it from your server with a proper media type to your script.

However, I find it strange how you manage to keep ignoring the lower part of
my postings which, if noticed, would bring you an almost instant solution.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
 
Reply With Quote
 
Doug Miller
Guest
Posts: n/a
 
      09-26-2007
In article <(E-Mail Removed)>, Thomas 'PointedEars' Lahn <(E-Mail Removed)> wrote:

>However, I find it strange how you manage to keep ignoring the lower part of
>my postings which, if noticed, would bring you an almost instant solution.


I'm not "ignoring" it -- it didn't work. If I've done something wrong here, I
don't see it.

if ( objSrvHTTP.status == 200 ) {

// This displays correctly...
XMLResponse.innerText = objSrvHTTP.responseText;

// ----- begin cut-and-paste of text from the link you provided ----
// with hopefully appropriate substitution in the parameter string
// for loadXML() -- if incorrect, please advise

var xmlDocument = new ActiveXObject ("Microsoft.XMLDOM");

loaded = xmlDocument.loadXML(objSrvHTTP.responseText);
if (!loaded) {
alert(xmlDocument.parseError.reason + xmlDocument.parseError.srcText);
}
// ----- end cut-and-paste -----------------------------------------------

var package = loaded.getElementsByTagName("Package");

// "Object doesn't support this property or method"

--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.
 
Reply With Quote
 
Doug Miller
Guest
Posts: n/a
 
      09-26-2007
In article <46fa816b$0$16109$(E-Mail Removed)-online.net>, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

>XMLHTTP and responseXML will only work if the server sends the XML with
>the HTTP response header Content-Type with value text/xml or
>application/xml.


That would explain it, then: the server is sending back no Content-Type header
*at all*.

Any suggestions on how to proceed? (Other than complaining to the server
administrator, that is.) Please note that I'm working in IE6 (not by choice,
but that's the way it is), and the overrideMimeType() method is not available.


--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      09-26-2007
Doug Miller wrote:
> [...] Thomas 'PointedEars' Lahn [...] wrote:


Please don't post my Reply-To address! I use it so that spammers have a
harder time spamming me; they usually spam only the From address, which
is seldom read and heavily filtered, in contrast to the Reply-To.

>> However, I find it strange how you manage to keep ignoring the lower part of
>> my postings which, if noticed, would bring you an almost instant solution.

>
> I'm not "ignoring" it -- it didn't work. If I've done something wrong here, I
> don't see it.
>
> [...]> // ----- begin cut-and-paste of text from the link you provided ----
> // with hopefully appropriate substitution in the parameter string
> // for loadXML() -- if incorrect, please advise
>
> var xmlDocument = new ActiveXObject ("Microsoft.XMLDOM");
>


If only it was "cut-and-paste" (rather "copy-and-paste"). The original code
also contains

xmlDocument.async = false;

However, it appears that this does not matter here.

> loaded = xmlDocument.loadXML(objSrvHTTP.responseText);


Again no real copy-and-paste. Martin declared the variable in his example.
It would seem you only copied the "bad" part.

> if (!loaded) {
> alert(xmlDocument.parseError.reason + xmlDocument.parseError.srcText);
> }
> // ----- end cut-and-paste -----------------------------------------------


So far, so good.

> var package = loaded.getElementsByTagName("Package");


Wrong. `loaded' is _not_ a reference to the (IXML)DOMDocument object;
`xmlDocument' is. However, you will observe that the latter object also has
no getElementsByTagName() method:

http://msdn2.microsoft.com/en-us/library/ms757878.aspx

It has a `childNodes' property that you can use, though.

> // "Object doesn't support this property or method"


BAD. Broken as designed.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$(E-Mail Removed)>
 
Reply With Quote
 
Doug Miller
Guest
Posts: n/a
 
      09-27-2007
In article <(E-Mail Removed)>, Thomas 'PointedEars' Lahn <(E-Mail Removed)> wrote:
>Doug Miller wrote:
>> [...] Thomas 'PointedEars' Lahn [...] wrote:

>
>Please don't post my Reply-To address! I use it so that spammers have a
>harder time spamming me; they usually spam only the From address, which
>is seldom read and heavily filtered, in contrast to the Reply-To.


Sorry about that -- didn't realize my newsreader was configured that way.
Should be fixed now.
>
>>> However, I find it strange how you manage to keep ignoring the lower part of
>>> my postings which, if noticed, would bring you an almost instant solution.

>>
>> I'm not "ignoring" it -- it didn't work. If I've done something wrong here, I
>> don't see it.
>>
>> [...]> // ----- begin cut-and-paste of text from the link you provided ----
>> // with hopefully appropriate substitution in the parameter string
>> // for loadXML() -- if incorrect, please advise
>>
>> var xmlDocument = new ActiveXObject ("Microsoft.XMLDOM");
>>

>
>If only it was "cut-and-paste" (rather "copy-and-paste"). The original code
>also contains
>
> xmlDocument.async = false;
>
>However, it appears that this does not matter here.


No, it doesn't. I realized that I'd omitted it just after I posted this, and
put it in -- with, as I'm sure you're already aware, no difference.
>
>> loaded = xmlDocument.loadXML(objSrvHTTP.responseText);

>
>Again no real copy-and-paste.


Which I noted when I posted it; refer to the 2nd & 3rd lines in particular:

<quote>
// ----- begin cut-and-paste of text from the link you provided ---
// with hopefully appropriate substitution in the parameter string
// for loadXML() -- if incorrect, please advise
</quote>

>Martin declared the variable in his example.
> It would seem you only copied the "bad" part.
>
>> if (!loaded) {
>> alert(xmlDocument.parseError.reason + xmlDocument.parseError.srcText);
>> }
>> // ----- end cut-and-paste -----------------------------------------------

>
>So far, so good.
>
>> var package = loaded.getElementsByTagName("Package");

>
>Wrong. `loaded' is _not_ a reference to the (IXML)DOMDocument object;
>`xmlDocument' is.


Oops. Right you are. Thanks.

> However, you will observe that the latter object also has
>no getElementsByTagName() method:
>
>http://msdn2.microsoft.com/en-us/library/ms757878.aspx
>
>It has a `childNodes' property that you can use, though.


Yes, it does, and that returns the root node perfectly. Thank you.

However -- neither childNodes nor getElementsByTagName succeeds in retrieving
any other elements.

What am I missing here?

--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.
 
Reply With Quote
 
Doug Miller
Guest
Posts: n/a
 
      09-27-2007
In article <GECKi.1251$(E-Mail Removed)>, (E-Mail Removed) (Doug Miller) wrote:
>In article <(E-Mail Removed)>, Thomas 'PointedEars' Lahn
> <(E-Mail Removed)> wrote:
>>Doug Miller wrote:
>>> [...] Thomas 'PointedEars' Lahn [...] wrote:

>>
>>Please don't post my Reply-To address! I use it so that spammers have a
>>harder time spamming me; they usually spam only the From address, which
>>is seldom read and heavily filtered, in contrast to the Reply-To.

>
>Sorry about that -- didn't realize my newsreader was configured that way.
>Should be fixed now.
>>
>>>> However, I find it strange how you manage to keep ignoring the lower part

> of
>>>> my postings which, if noticed, would bring you an almost instant solution.
>>>
>>> I'm not "ignoring" it -- it didn't work. If I've done something wrong here,

> I
>>> don't see it.
>>>
>>> [...]> // ----- begin cut-and-paste of text from the link you provided ----
>>> // with hopefully appropriate substitution in the parameter string
>>> // for loadXML() -- if incorrect, please advise
>>>
>>> var xmlDocument = new ActiveXObject ("Microsoft.XMLDOM");
>>>

>>
>>If only it was "cut-and-paste" (rather "copy-and-paste"). The original code
>>also contains
>>
>> xmlDocument.async = false;
>>
>>However, it appears that this does not matter here.

>
>No, it doesn't. I realized that I'd omitted it just after I posted this, and
>put it in -- with, as I'm sure you're already aware, no difference.
>>
>>> loaded = xmlDocument.loadXML(objSrvHTTP.responseText);

>>
>>Again no real copy-and-paste.

>
>Which I noted when I posted it; refer to the 2nd & 3rd lines in particular:
>
><quote>
>// ----- begin cut-and-paste of text from the link you provided ---
>// with hopefully appropriate substitution in the parameter string
>// for loadXML() -- if incorrect, please advise
></quote>
>
>>Martin declared the variable in his example.
>> It would seem you only copied the "bad" part.
>>
>>> if (!loaded) {
>>> alert(xmlDocument.parseError.reason + xmlDocument.parseError.srcText);
>>> }
>>> // ----- end cut-and-paste -----------------------------------------------

>>
>>So far, so good.
>>
>>> var package = loaded.getElementsByTagName("Package");

>>
>>Wrong. `loaded' is _not_ a reference to the (IXML)DOMDocument object;
>>`xmlDocument' is.

>
>Oops. Right you are. Thanks.
>
>> However, you will observe that the latter object also has
>>no getElementsByTagName() method:
>>
>>http://msdn2.microsoft.com/en-us/library/ms757878.aspx
>>
>>It has a `childNodes' property that you can use, though.

>
>Yes, it does, and that returns the root node perfectly. Thank you.
>
>However -- neither childNodes nor getElementsByTagName succeeds in retrieving
>any other elements.
>
>What am I missing here?
>

Never mind -- I see what I did wrong there (forgot there was an intervening
layer of elements between that, and the one I wanted). Making progress.

Thank you VERY much for your help so far. I know I made some dumb errors.

--
Regards,
Doug Miller (alphageek at milmac dot com)

It's time to throw all their damned tea in the harbor again.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to reply to posts on google groups (and not reply to just author) davidj411 Python 1 05-27-2008 04:13 PM
Reply....Reply All not in Browser Denny B Computer Support 3 04-24-2006 01:59 PM
can sombody tell me how to reply to sombody elses message and include the original message in the reply? Computer Support 3 08-24-2003 12:58 PM
Re: can sombody tell me how to reply to sombody elses message and include the original message in the reply? Computer Support 0 07-24-2003 09:21 PM



Advertisments