OK got non-standard attributes. It forces one rule, that all non-
standard attributes for an element must follow 'id' and 'label'. This
is standardized in setting "var z=2", as it skips past the first
attributes and finds the remaining. Though this is a lot of code for
each level of elements;
var
Slick, and super fast. Makes it so that I do not even want to move
onto JSON ;-)... (JK, my engineers are forcing me too)
Made some minor mods, these add a little time and still processes over
50K lines in about 6-8 seconds, and 100K right about 10 seconds. Now
everything is its own html object re
I don't know why Google Groups keeps inserting those semi-random blank lines
in the code! Now I'm curious, so I'm trying something a bit different -
let's see what happens..
function parseXml( xml ) {
var html = [];
html.push( '' );
$(xml).find('sites').$each( function( $site ) {
Cool, it will be good to see your continued work. We may be among the last
holdouts in this mailing list - but I figure since the thread started here
we can carry on.
BTW you may notice one bit of annoying repeated boilerplate in that last
version. See how the callback functions for all the .each(
OK, so this is much better than a lesson in parsing XML. Showing the
errors that I had made in my process, you have also shown sound jQuery
which I was having a hard time picking up from the documentation. I
tend to learn best by doing and getting feedback. Mike, thank you. I
am going to keep this
That is really nice. 100K lines really fast no script time outs. I
need to get back and study a little more. I was so terribly close, but
missed some really basic principles.
I was headed in this direction I was trying to get to the function
(i,parent),function(j,child) I had not quite figured that part out
which is obvious. Let's see what this does.
Thanks
Chad
No worries on the XML vs. JSON. It's been interesting to watch your progress
in refactoring the code. I hope it's useful for other people too.
A few notes on the latest version...
* Avoid using ALLCAPS or PARTIALcaps in a variable name. Many JavaScript
programmers will think you intend such varia
Let's me have multiple children:
function parseXml(xml) {
$(xml).find('sites').each(function(){
var PARENTarr = jQuery.makeArray($(this).find('>element'));
$(PARENTarr).each(function(i){
$("div").append(""+
This is better. The arrays are much more efficient, and I cut the code
by more than half. I know, I know JSON, I will get there, this is
teaching me way more though. I still would like to be able to
determine my level of nesting abstractly, and also getting out non-
standard attributes.
BTW proces
This is better. The arrays are much more efficient, and I cut the code
by more than half. I know, I know JSON, I will get there, this is
teaching me way more though. I still would like to be able to
determine my level of nesting abstractly, and also getting out non-
standard attributes.
function
OK this is some progress. Still want more abstraction where I can,
though this is much improved. I also need to be able to get arrays of
attributes abstractly.
function parseXml(xml) {
$(xml).find('sites').each(function(){
var PARENTarr = jQuery.makeArray($(this).
this treats processes each order of element separately as a variable.
If I can append these correctly. I think that this might be a slightly
better process. It is at least treating things in a more object
oriented manner.
$(xml).find('sites').each(function(){
PARENT = $(this);
Now I am treating each order of elements separately as their own
objects. This is much faster, if I can figure out how to append the
results correctly.
function parseXml(xml) {
$(xml).find('sites').each(function(){
PARENT = $(this);
var PAR
This gets the variables at the top level and gives me the correct
count for each level.
function parseXml(xml) {
$(xml).find('sites').each(function(){
var PARENT = $(this).children($(this).attr('id'));
var PARENTcount = PARE
Small Tweaks, less lines of code. Still no major breaks in breaking
the nested model for XML parsing. Things that I am interested in are
being able to determine levels of nesting abstractly, being able to
determine attributes abstractly, being able to hold results in an
Array, build the array, and
Mike,
Thanks so much for taking the time for writing this tutorial. I see
how this is effective. I attempted to do similar things with the XML
however...
The Data Objects for JSON are much more simplistic structurally, and a
little obtuse for reading visually. As I mentioned this simply is a
model
No offense, but that code is really frightening. Not your fault though.
JSON is not only much faster than all this XML/DOM garbage, but it is *much*
easier to understand and use too!
If you're coding JavaScript, you need to know how to use ordinary JavaScript
objects and arrays, yes?
If you know
Funny thing is, my lead engineer said the same thing...
Mostly this was an experiment to gain a better understanding of DOM
outside of HTML. This is about as exciting as a SAX parser when it
comes to speed (<5sec in safari for 20K lines, slightly longer in
FireFox, and noticeably longer in Chrome)
19 matches
Mail list logo