Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22790

Re: Data being skipped when parsing xml using javascript

Message-ID <4966154.XEByQThCZJ@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2014-01-26 00:41 +0100
Subject Re: Data being skipped when parsing xml using javascript
Newsgroups comp.lang.javascript
References <5516dee4-5c91-4194-877e-cf1cd4ce4bc4@googlegroups.com> <4205866.74lTBbsI5X@PointedEars.de> <44d93bd1-33e3-45b8-bb31-c7e6a086445b@googlegroups.com>

Show all headers | View raw


paul.lee.1971@googlemail.com wrote:

[restored attribution]

> [Thomas 'PointedEars' Lahn wrote: ]
>> 2. Watch for the scope of your identifiers.
> 
> Thanks, I'll put this in in the next iteration of my code. At the moment I
> just want to get something working before prettying it up. My knowledge of
> Ajax goes back at least five years and I've rarely touched it since then,
> so this is a good opportunity for me to revisit all the code I've written,
> which isn't much.

It is important for the correct operation of your program, especially as it 
uses a hand-crafted XHR (which you call “Ajax”) wrapper, that your 
identifiers do not have too much scope; otherwise you could end up reusing 
them, with side-effects.
 
>> 3. Your approach at processing the generated XML markup is both
>> inefficient
>>    and logically in error:
> 
> OK, thanks, I'm working on this now. It doesn't explain why data is being
> skipped […]

Why not?

>> 4. You should not fill a variable with concatenated string values in each
>>    iteration in order to assign to “innerHTML” later, but you should
>>    create and append element objects as child nodes:
> 
> OK, this is something for a later iteration. As I said, I just want to get
> the darned thing working ;)

You might generate invalid HTML if you use “innerHTML” and do not escape 
special characters in the retrieved element content.  This can cause content 
not to be displayed.

Creating and appending element objects prevents code injection and makes 
escaping unnecessary.  There are wrappers like my 
jsx.dom.createNodesFromObj() that reduce the amount of code that you have to 
write for this.

>> Next time, please post *some* code here (where you would replace tabs
>> with two spaces).  This is not the Web.
> 
> OK fair enough. In the past (not here) I have been lambasted for posting
> too much code.

And rightly so.  You had wasted precious resources of other people.

> When I said that all the code I put up was relevant, it evoked a flame
> war. Now I just put links up to the relevant pages. I've had my fingers
> bitten before, I don't want that to happen again. Hope you understand :(

I don't.  Emphasis was on “some”.  If you can post a reduced test case, it 
shows that you have basically understood what the code is doing.  Therefore, 
the assumption is that you are much more likely to find the bug yourself, 
while you are doing that, or after you have been given advice of which you 
have proven yourself worthy then.  Free time is a precious resource, too.

>> Finally, please avoid posting using the b0rken Google Groups, and post
>> using your real name.  TIA.
> 
> Are these groups "broken"? They seem OK to me.

If you are using Google Groups, you are using a Usenet archive that has been 
extended with an as yet Usenet-incompatible mail-to-news gateway; you are 
not using Usenet (as it was intended).  It also has built-in error-
correction, so that you see its errors only when you read those b0rken 
articles on Usenet.

Among other problems, it does not impose the customary 80-characters limit 
on line length or even tells you that you should do that; each of your 
paragraphs was posted as one looong line (> 230 characters).  Only lucky for 
you, my newsreader can correct this problem when *replying* (reading the 
original text was a PITA, though, despite client-side word-wrap).  Other of 
its bugs are not as easily corrected; for example, empty quoted lines are 
sometimes inserted between each quoted line, bloating the article and making 
it virtually unreadable.

And then there is the spam problem.  Google Groups is a source of spam as 
spam is not regulated/deleted there in such a way that *all* Usenet users 
can benefit from it.  Spammer's accounts are not canceled there even upon 
numerous complaints; spam and other abuse is only hidden from Google Groups 
users.

> I rarely post on the groups, so much so that I haven't even set my real
> name, but I hope that it would be obvious from my address.

Addresses are for mailboxes; names are for people.  I do not communicate 
with mailboxes on the Net; I communicate with people.

Please also leave the attribution line next time, shorten it if possible 
(yet another GG bug to work around).

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Data being skipped when parsing xml using javascript paul.lee.1971@googlemail.com - 2014-01-25 11:05 -0800
  Re: Data being skipped when parsing xml using javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-25 21:19 +0100
    Re: Data being skipped when parsing xml using javascript paul.lee.1971@googlemail.com - 2014-01-25 14:04 -0800
      Re: Data being skipped when parsing xml using javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-01-26 00:41 +0100
  Re: Data being skipped when parsing xml using javascript Martin Honnen <mahotrash@yahoo.de> - 2014-01-26 11:25 +0100

csiph-web