While I understand that it's a node, I'm wondering if there's an option
that I can disable the output of such nodes since they screw up my
application. Yes, it is definitely possible to have JavaScript check if
a node is a whitespace node and ignore it, but it gets annoying that I
have to program around it _every single time_. It would be so much
easier to just do this:
// where firstChild is the root element and where I want childNode[0]
to be the string node returned from the webservice
var nodeImLookingFor = serverResponse.firstChild.childNode[0];
.... rather than this ...
// what happens if msft suddenly disables whitespace by default on me
or Opera / IE6 handle it one way and Safari / Firefox / IE7 handle it
another?
// would I have to make cases for each browser then??
var nodeImLookingFor;
if (isIE)
nodeImLookingFor = serverResponse.firstChild.childNode[0];
else
nodeImLookingFor = serverResponse.firstChild.childNode[1];
.... or this ...
// this is a pain to do every time if all I want is the first node!
var nodeImLookingFor;
for (var i = 0; i < nodeImLookingFor.childNodes.length; i++) {
if (serverResponse.childNodes[i].nodeType == 3)
continue;
nodeImLookingFor = serverResponse.childNodes[i];
}
See how silly it is to have to either a) write a global function that I
have to remember to include in every project I do that will fix this,
or b) manually program around it every time? I assure you that,
considering how often I have to address the issue, disabling the output
of unnecessary whitespace nodes will be worth it for me and any other
developer that has to contend with differences in how JavaScript is
handled in different browsers and the annoyance of having to work
around it as often as I have to.
On Nov 8, 4:22 am, "John Saunders" <john.saunders at trizetto.com>
[quoted text, click to view] wrote:
> <amat...@gmail.com> wrote in messagenews:1162966410.896882.24920@m7g2000cwm.googlegroups.com...
>
> > Like I said, it's not so much about bandwidth as much as it is a pain
> > to deal with in all of my JavaScript apps that count the whitespace as
> > actual nodes.Whitespace _is_ a node. It's a whitespace node, not an element or attribute.
> If your JavaScript code ignores whitespace nodes (as it no doubt ignores
> comment nodes), then it should have no problems.
>
> Am I mistaken?
>
> John
It's becoming quite pointless to argue with you here, but I'll bite
once more even though I was just looking for a quick fix.
I'm absolutely, definitely not looking to ignore any standards -- take
a look at my example code above if you don't believe me. Even though
Microsoft's own IE 6 _does_ ignore the standard that the whitespace is
a node, Firefox does not. Therefore, I have to program around it to be
truly standards compliant. If I wanted to ignore standards, I'd just
let IE's busted XML parsing engine ignore the standards for me.
I suppose that, overall, I'm really frustrated that I don't have
control over the output of my webservice. I'm not complaining that
whitespace or comments shouldn't be nodes. I'm just wondering if there
was a way I could disable the automatic output of them so I don't have
to deal with them in my code. Is it really that unreasonable to think
that, if I just wanted to return a single string node without any
whitespace or comments, I could?
Goodness. I didn't expect to start a flame war or bash any standards /
companies. I'm just looking for some quick help from someone else who
might be better educated on webservice output than I am.
On Nov 8, 9:12 pm, "John Saunders" <john.saunders at trizetto.com>
[quoted text, click to view] wrote:
> <amat...@gmail.com> wrote in messagenews:1163006629.765776.38730@f16g2000cwb.googlegroups.com...
>
> > While I understand that it's a node, I'm wondering if there's an option
> > that I can disable the output of such nodes since they screw up my
> > application. Yes, it is definitely possible to have JavaScript check if
> > a node is a whitespace node and ignore it, but it gets annoying that I
> > have to program around it _every single time_. It would be so much
> > easier to just do this:
>
> > // where firstChild is the root element and where I want childNode[0]
> > to be the string node returned from the webservice
> > var nodeImLookingFor = serverResponse.firstChild.childNode[0];(sigh) If you insist on ignoring important details of the standards you're
> using, then you're going to have problems.
>
> Whitespace nodes and comment nodes are to be expected. Even if you could get
> .NET to stop sending the whitespace today, you still could not guarantee
> that a comment node wouldn't slip in somehow.
>
> John
You are correct in that I don't want to be bothered to write code that
I don't believe I should have to and that I believe there should be an
easy fix for. It seems that Microsoft even recognized this issue by
including a PreserveWhitespace property on the XmlDocument class, but
missed the inclusion of it into the webservice as far as I can tell. I
was just looking for someone else to confirm this for me.
You're argument for me coding around something "that's not supposed to
matter" is really quite juvenile if you think about it. The point your
trying to make does not target my original question at all (which,
again, has nothing to do with standards but rather the output of the
data). It's almost as if you're arguing with me because you don't have
a good answer and you just feel like arguing.
For anyone else suggesting any information on a fix, I would also like
to point out that I will have full control over the JavaScript,
webservice, servers, and any / all server-side caches and/or proxies
for the lifetime of the applications I make. Therefore, I won't need to
worry about any random third parties injecting whitespace or comments
into my XML via SOAP extensions or anything else.
[quoted text, click to view] <amattie@gmail.com> wrote in message
news:1163092479.724233.145790@b28g2000cwb.googlegroups.com...
> It's becoming quite pointless to argue with you here, but I'll bite
> once more even though I was just looking for a quick fix.
The reason you're unlikely to find a quick fix is that you're trying to fix
something that's not supposed to matter. You appear to want the fix because
it appears that you can't be bothered to write code which takes into
consideration that whitespace and comment nodes may be interspersed with
other nodes. My point was simply that you don't need the quick fix if you
cod to the standard.
Obviously, if someone reading this knows of the quick fix the OP is looking
for, then please provide it. When you do provide the quick fix, you should
probably indicate whether the fix is likely to break in the future. For
instance, will his code break if he some day configures his web service with
a Soap Extension that happens to produce whitespace nodes.
John
[quoted text, click to view] <amattie@gmail.com> wrote in message
news:1163098348.322073.239450@b28g2000cwb.googlegroups.com...
> You are correct in that I don't want to be bothered to write code that
> I don't believe I should have to and that I believe there should be an
> easy fix for. It seems that Microsoft even recognized this issue by
> including a PreserveWhitespace property on the XmlDocument class, but
> missed the inclusion of it into the webservice as far as I can tell. I
> was just looking for someone else to confirm this for me.
>
> You're argument for me coding around something "that's not supposed to
> matter" is really quite juvenile if you think about it. The point your
> trying to make does not target my original question at all (which,
> again, has nothing to do with standards but rather the output of the
> data).
XML web services aren't standards-based?
[quoted text, click to view] >It's almost as if you're arguing with me because you don't have
> a good answer and you just feel like arguing.
>
> For anyone else suggesting any information on a fix, I would also like
> to point out that I will have full control over the JavaScript,
> webservice, servers, and any / all server-side caches and/or proxies
> for the lifetime of the applications I make. Therefore, I won't need to
> worry about any random third parties injecting whitespace or comments
> into my XML via SOAP extensions or anything else.
In this case, you'd be fine, unless Microsoft changed the output format.
That's not something you have control over.
John
Don't see what you're looking for? Try a search.